blob: 94f4d39acbbeaeccd0411d545cd433787509b3ed [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>();
Mike Schuchardt2df08912020-12-15 16:28:09 -0800227 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&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>();
Mike Schuchardt2df08912020-12-15 16:28:09 -0800235 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&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>();
Mike Schuchardt2df08912020-12-15 16:28:09 -0800243 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jason Macnak5c954952019-07-09 15:46:12 -0700244 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>();
Mike Schuchardt2df08912020-12-15 16:28:09 -0800251 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&ray_tracing_props);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500252 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>();
Mike Schuchardt2df08912020-12-15 16:28:09 -0800259 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&acc_structure_props);
sourav parmarcd5fb182020-07-17 12:58:44 -0700260 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>();
Mike Schuchardt2df08912020-12-15 16:28:09 -0800267 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&transform_feedback_props);
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700268 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
Mike Schuchardt2df08912020-12-15 16:28:09 -0800346 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
John Zulaufde972ac2017-10-26 12:07:05 -0600347 if (features2) {
Mike Schuchardt2df08912020-12-15 16:28:09 -0800348 // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700349 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mike Schuchardt2df08912020-12-15 16:28:09 -0800350 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700351 "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
Mike Schuchardt2df08912020-12-15 16:28:09 -0800888 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -0500889 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 |
Mike Schuchardt2df08912020-12-15 16:28:09 -08001095 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT);
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001096 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
Mike Schuchardt2df08912020-12-15 16:28:09 -08003348bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *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) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08003668 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003669 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
Mike Schuchardt2df08912020-12-15 16:28:09 -08004262void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *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
Mike Schuchardt2df08912020-12-15 16:28:09 -08004295 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext);
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004296 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004297 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) {
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 "
Mike Schuchardt2df08912020-12-15 16:28:09 -08004300 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT.");
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 {
Mike Schuchardt2df08912020-12-15 16:28:09 -08004339 const auto *bda_features = lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext);
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004340 if (bda_features) {
4341 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4342 buffer_device_address = bda_features->bufferDeviceAddress;
4343 }
4344 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004345 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004346 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004347 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004348 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004349 }
Mike Schuchardt2df08912020-12-15 16:28:09 -08004350 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004351 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
Mike Schuchardt2df08912020-12-15 16:28:09 -08004352 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004353 }
4354 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004355 }
4356 return skip;
4357}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004358
Jason Macnak192fa0e2019-07-26 15:07:16 -07004359bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004360 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004361 bool skip = false;
4362
4363 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4364 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4365 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004366 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004367 } else {
4368 uint32_t vertex_component_size = 0;
4369 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4370 vertex_component_size = 4;
4371 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4372 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4373 vertex_component_size = 2;
4374 }
4375 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004376 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004377 }
4378 }
4379
4380 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4381 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004382 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004383 } else {
4384 uint32_t index_element_size = 0;
4385 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4386 index_element_size = 4;
4387 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4388 index_element_size = 2;
4389 }
4390 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004391 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004392 }
4393 }
4394 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4395 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004396 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004397 }
4398 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004399 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004400 }
4401 }
4402
4403 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004404 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004405 }
4406
4407 return skip;
4408}
4409
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004410bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4411 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004412 bool skip = false;
4413
4414 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004415 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004416 }
4417 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004418 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004419 }
4420
4421 return skip;
4422}
4423
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004424bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4425 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004426 bool skip = false;
4427 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004428 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004429 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004430 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004431 }
4432 return skip;
4433}
4434
4435bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004436 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004437 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004438 bool skip = false;
4439 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004440 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4441 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4442 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004443 }
4444 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004445 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4446 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4447 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004448 }
4449 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4450 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004451 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4452 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4453 "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 -07004454 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004455 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004456 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004457 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4458 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004459 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4460 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004461 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004462 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004463 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4464 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4465 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004466 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004467 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004468 uint64_t total_triangle_count = 0;
4469 for (uint32_t i = 0; i < info.geometryCount; i++) {
4470 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004471
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004472 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004473
Jason Macnak5c954952019-07-09 15:46:12 -07004474 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4475 continue;
4476 }
4477 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4478 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004479 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004480 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4481 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4482 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004483 }
4484 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004485 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4486 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4487 for (uint32_t i = 1; i < info.geometryCount; i++) {
4488 const VkGeometryNV &geometry = info.pGeometries[i];
4489 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004490 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004491 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4492 "info.pGeometries[0].geometryType.",
4493 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004494 }
4495 }
4496 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004497 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4498 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4499 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4500 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4501 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4502 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4503 }
4504 }
4505 skip |=
4506 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004507 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004508 return skip;
4509}
4510
Ricardo Garciaa4935972019-02-21 17:43:18 +01004511bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4512 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004513 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004514 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004515 if (pCreateInfo) {
4516 if ((pCreateInfo->compactedSize != 0) &&
4517 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004518 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4519 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4520 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4521 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004522 }
Jason Macnak5c954952019-07-09 15:46:12 -07004523
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004524 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004525 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004526 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004527 return skip;
4528}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004529
Jeff Bolz5c801d12019-10-09 10:38:45 -05004530bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4531 const VkAccelerationStructureInfoNV *pInfo,
4532 VkBuffer instanceData, VkDeviceSize instanceOffset,
4533 VkBool32 update, VkAccelerationStructureNV dst,
4534 VkAccelerationStructureNV src, VkBuffer scratch,
4535 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004536 bool skip = false;
4537
4538 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004539 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004540 }
4541
4542 return skip;
4543}
4544
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004545bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4546 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4547 VkAccelerationStructureKHR *pAccelerationStructure) const {
4548 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004549 const auto *acceleration_structure_features =
4550 lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
4551 if (!acceleration_structure_features ||
4552 (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) {
4553 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611",
4554 "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled");
4555 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004556 if (pCreateInfo) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004557 if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR &&
4558 (!acceleration_structure_features ||
4559 (acceleration_structure_features && acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) {
sourav parmara96ab1a2020-04-25 16:28:23 -07004560 skip |=
sourav parmarcd5fb182020-07-17 12:58:44 -07004561 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613",
4562 "vkCreateAccelerationStructureKHR(): If createFlags includes "
4563 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, "
4564 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE");
sourav parmara96ab1a2020-04-25 16:28:23 -07004565 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004566 if (pCreateInfo->deviceAddress &&
4567 !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
4568 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612",
4569 "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include "
4570 "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR");
4571 }
4572 if (SafeModulo(pCreateInfo->offset, 256) != 0) {
4573 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734",
4574 "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset);
4575 }
sourav parmar83c31b12020-05-06 12:30:54 -07004576 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004577 return skip;
4578}
4579
Jason Macnak5c954952019-07-09 15:46:12 -07004580bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4581 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004582 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004583 bool skip = false;
4584 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004585 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4586 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004587 }
4588 return skip;
4589}
4590
sourav parmarcd5fb182020-07-17 12:58:44 -07004591bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV(
4592 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures,
4593 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
4594 bool skip = false;
4595 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
4596 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
4597 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432",
4598 "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be "
4599 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
4600 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
4601 }
4602 return skip;
4603}
4604
Peter Chen85366392019-05-14 15:20:11 -04004605bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4606 uint32_t createInfoCount,
4607 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4608 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004609 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004610 bool skip = false;
4611
4612 for (uint32_t i = 0; i < createInfoCount; i++) {
4613 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4614 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004615 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004616 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4617 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4618 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4619 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004620 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004621
4622 const auto *pipeline_cache_contol_features =
4623 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4624 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4625 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4626 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4627 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4628 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4629 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4630 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4631 }
4632 }
4633
sourav parmarf4a78252020-04-10 13:04:21 -07004634 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4635 skip |=
4636 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4637 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4638 }
4639 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4640 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4641 skip |=
4642 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4643 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4644 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4645 }
4646 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4647 if (pCreateInfos[i].basePipelineIndex != -1) {
4648 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4649 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4650 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4651 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4652 "and pCreateInfos->basePipelineIndex is not -1.");
4653 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004654 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004655 skip |=
4656 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4657 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4658 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4659 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4660 "that element.");
4661 }
sourav parmarf4a78252020-04-10 13:04:21 -07004662 }
4663 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004664 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004665 skip |=
4666 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4667 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4668 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4669 "commands pCreateInfos parameter.");
4670 }
4671 } else {
4672 if (pCreateInfos[i].basePipelineIndex != -1) {
4673 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4674 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4675 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4676 }
4677 }
4678 }
4679 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4680 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4681 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4682 }
4683 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4684 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4685 "vkCreateRayTracingPipelinesNV: flags must not include "
4686 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4687 }
4688 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4689 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4690 "vkCreateRayTracingPipelinesNV: flags must not include "
4691 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4692 }
4693 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4694 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4695 "vkCreateRayTracingPipelinesNV: flags must not include "
4696 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4697 }
4698 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4699 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4700 "vkCreateRayTracingPipelinesNV: flags must not include "
4701 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4702 }
4703 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4704 skip |= LogError(
4705 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4706 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4707 }
4708 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4709 skip |= LogError(
4710 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4711 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4712 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004713 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) {
4714 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588",
4715 "vkCreateRayTracingPipelinesNV: flags must not include "
4716 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4717 }
4718 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4719 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816",
4720 "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
4721 }
Peter Chen85366392019-05-14 15:20:11 -04004722 }
4723
4724 return skip;
4725}
4726
sourav parmarcd5fb182020-07-17 12:58:44 -07004727bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(
4728 VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount,
4729 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004730 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07004731 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
4732 if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) {
4733 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586",
4734 "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07004735 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004736 for (uint32_t i = 0; i < createInfoCount; i++) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004737 if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) {
4738 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4739 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596",
4740 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4741 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4742 }
4743 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4744 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597",
4745 "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, "
4746 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR.");
4747 }
4748 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004749 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4750 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4751 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
sourav parmarcd5fb182020-07-17 12:58:44 -07004752 "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32
4753 "], When chained to VkRayTracingPipelineCreateInfoKHR, "
4754 "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004755 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4756 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4757 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004758 const auto *pipeline_cache_contol_features =
4759 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4760 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4761 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4762 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4763 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
sourav parmarcd5fb182020-07-17 12:58:44 -07004764 "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled,"
sourav parmara96ab1a2020-04-25 16:28:23 -07004765 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4766 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4767 }
4768 }
sourav parmarf4a78252020-04-10 13:04:21 -07004769 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
sourav parmarcd5fb182020-07-17 12:58:44 -07004770 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4771 "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
sourav parmarf4a78252020-04-10 13:04:21 -07004772 }
4773 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004774 if (pCreateInfos[i].pLibraryInterface == NULL) {
sourav parmarf4a78252020-04-10 13:04:21 -07004775 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
sourav parmarcd5fb182020-07-17 12:58:44 -07004776 "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, "
4777 "pLibraryInterface must not be NULL.");
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004778 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004779 }
4780 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) {
4781 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816",
4782 "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag.");
sourav parmarf4a78252020-04-10 13:04:21 -07004783 }
4784 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4785 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4786 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4787 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4788 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4789 skip |= LogError(
4790 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
sourav parmarcd5fb182020-07-17 12:58:44 -07004791 "vkCreateRayTracingPipelinesKHR: If flags includes "
4792 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004793 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4794 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4795 "must not be VK_SHADER_UNUSED_KHR");
4796 }
4797 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4798 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4799 skip |= LogError(
4800 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
sourav parmarcd5fb182020-07-17 12:58:44 -07004801 "vkCreateRayTracingPipelinesKHR: If flags includes "
4802 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
sourav parmarf4a78252020-04-10 13:04:21 -07004803 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4804 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4805 "element must not be VK_SHADER_UNUSED_KHR");
4806 }
4807 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004808 if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE &&
4809 pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) {
4810 if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) {
4811 skip |= LogError(
4812 device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599",
4813 "vkCreateRayTracingPipelinesKHR: If "
4814 "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is "
4815 "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must "
4816 "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR.");
4817 }
4818 }
sourav parmarf4a78252020-04-10 13:04:21 -07004819 }
4820 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4821 if (pCreateInfos[i].basePipelineIndex != -1) {
4822 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4823 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
sourav parmarcd5fb182020-07-17 12:58:44 -07004824 "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be "
sourav parmarf4a78252020-04-10 13:04:21 -07004825 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4826 "and pCreateInfos->basePipelineIndex is not -1.");
4827 }
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07004828 if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004829 skip |=
4830 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4831 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4832 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4833 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4834 "element.");
4835 }
sourav parmarf4a78252020-04-10 13:04:21 -07004836 }
4837 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004838 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004839 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
sourav parmarcd5fb182020-07-17 12:58:44 -07004840 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004841 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4842 "commands pCreateInfos parameter %d.",
4843 pCreateInfos[i].basePipelineIndex, createInfoCount);
4844 }
4845 } else {
4846 if (pCreateInfos[i].basePipelineIndex != -1) {
4847 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
sourav parmarcd5fb182020-07-17 12:58:44 -07004848 "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
sourav parmarf4a78252020-04-10 13:04:21 -07004849 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4850 }
4851 }
4852 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004853 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR &&
4854 (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) {
4855 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598",
4856 "vkCreateRayTracingPipelinesKHR: If flags includes "
4857 "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, "
4858 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled.");
sourav parmarf4a78252020-04-10 13:04:21 -07004859 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004860 bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library);
4861 if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) {
4862 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595",
4863 "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, "
4864 "pLibraryInfo and pLibraryInterface must be NULL.");
sourav parmarf4a78252020-04-10 13:04:21 -07004865 }
sourav parmarcd5fb182020-07-17 12:58:44 -07004866 if (pCreateInfos[i].pLibraryInfo) {
4867 if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) {
4868 if (pCreateInfos[i].stageCount == 0) {
4869 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600",
4870 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4871 "stageCount must not be 0.");
4872 }
4873 if (pCreateInfos[i].groupCount == 0) {
4874 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601",
4875 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, "
4876 "groupCount must not be 0.");
4877 }
4878 } else {
4879 if (pCreateInfos[i].pLibraryInterface == NULL) {
4880 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590",
4881 "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member "
4882 "is greater than 0, its "
4883 "pLibraryInterface member must not be NULL.");
4884 }
4885 }
4886 }
4887 if (pCreateInfos[i].pLibraryInterface) {
4888 if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize >
4889 phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) {
4890 skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605",
4891 "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to "
4892 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize.");
4893 }
4894 }
4895 if (deferredOperation != VK_NULL_HANDLE) {
4896 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) {
4897 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587",
4898 "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of "
4899 "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
sourav parmarf4a78252020-04-10 13:04:21 -07004900 }
4901 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004902 }
4903
4904 return skip;
4905}
4906
Mike Schuchardt21638df2019-03-16 10:52:02 -07004907#ifdef VK_USE_PLATFORM_WIN32_KHR
4908bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4909 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004910 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004911 bool skip = false;
4912 if (!device_extensions.vk_khr_swapchain)
4913 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4914 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4915 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4916 if (!device_extensions.vk_khr_surface)
4917 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4918 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4919 skip |=
4920 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4921 if (!device_extensions.vk_ext_full_screen_exclusive)
4922 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4923 skip |= validate_struct_type(
4924 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4925 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4926 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4927 if (pSurfaceInfo != NULL) {
4928 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4929 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4930 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4931
4932 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4933 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4934 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4935 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004936 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4937 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004938
4939 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4940 }
4941 return skip;
4942}
4943#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004944
4945bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4946 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004947 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004948 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4949 bool skip = false;
Mike Schuchardt2df08912020-12-15 16:28:09 -08004950 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004951 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4952 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4953 }
4954 return skip;
4955}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004956
4957bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004958 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004959 bool skip = false;
4960
4961 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004962 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4963 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004964 }
4965
4966 return skip;
4967}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004968
4969bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004970 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004971 bool skip = false;
4972
4973 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004974 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4975 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004976 }
4977
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004978 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004979 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004980 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4981 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004982 }
4983
4984 return skip;
4985}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004986
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004987bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4988 uint32_t bindingCount, const VkBuffer *pBuffers,
4989 const VkDeviceSize *pOffsets) const {
4990 bool skip = false;
4991 if (firstBinding > device_limits.maxVertexInputBindings) {
4992 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4993 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4994 device_limits.maxVertexInputBindings);
4995 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4996 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4997 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4998 "maxVertexInputBindings (%u)",
4999 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5000 }
5001
Jeff Bolz165818a2020-05-08 11:19:03 -05005002 for (uint32_t i = 0; i < bindingCount; ++i) {
5003 if (pBuffers[i] == VK_NULL_HANDLE) {
5004 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
5005 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5006 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
5007 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5008 } else {
5009 if (pOffsets[i] != 0) {
5010 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
5011 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5012 }
5013 }
5014 }
5015 }
5016
sfricke-samsung4ada8d42020-02-09 17:43:11 -08005017 return skip;
5018}
5019
Mark Lobodzinski84988402019-09-11 15:27:30 -06005020bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005021 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005022 bool skip = false;
5023 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005024 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
5025 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005026 }
5027 return skip;
5028}
5029
5030bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05005031 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06005032 bool skip = false;
5033 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005034 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
5035 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06005036 }
5037 return skip;
5038}
Petr Kraus3d720392019-11-13 02:52:39 +01005039
5040bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
5041 VkSemaphore semaphore, VkFence fence,
5042 uint32_t *pImageIndex) const {
5043 bool skip = false;
5044
5045 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005046 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
5047 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005048 }
5049
5050 return skip;
5051}
5052
5053bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
5054 uint32_t *pImageIndex) const {
5055 bool skip = false;
5056
5057 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005058 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
5059 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01005060 }
5061
5062 return skip;
5063}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005064
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005065bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
5066 uint32_t firstBinding, uint32_t bindingCount,
5067 const VkBuffer *pBuffers,
5068 const VkDeviceSize *pOffsets,
5069 const VkDeviceSize *pSizes) const {
5070 bool skip = false;
5071
5072 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
5073 for (uint32_t i = 0; i < bindingCount; ++i) {
5074 if (pOffsets[i] & 3) {
5075 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
5076 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
5077 }
5078 }
5079
5080 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5081 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
5082 "%s: The firstBinding(%" PRIu32
5083 ") index is greater than or equal to "
5084 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5085 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5086 }
5087
5088 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5089 skip |=
5090 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
5091 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
5092 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5093 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5094 }
5095
5096 for (uint32_t i = 0; i < bindingCount; ++i) {
5097 // pSizes is optional and may be nullptr.
5098 if (pSizes != nullptr) {
5099 if (pSizes[i] != VK_WHOLE_SIZE &&
5100 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
5101 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
5102 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
5103 ") is not VK_WHOLE_SIZE and is greater than "
5104 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
5105 cmd_name, i, pSizes[i]);
5106 }
5107 }
5108 }
5109
5110 return skip;
5111}
5112
5113bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5114 uint32_t firstCounterBuffer,
5115 uint32_t counterBufferCount,
5116 const VkBuffer *pCounterBuffers,
5117 const VkDeviceSize *pCounterBufferOffsets) const {
5118 bool skip = false;
5119
5120 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
5121 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5122 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
5123 "%s: The firstCounterBuffer(%" PRIu32
5124 ") index is greater than or equal to "
5125 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5126 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5127 }
5128
5129 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5130 skip |=
5131 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
5132 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5133 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5134 cmd_name, firstCounterBuffer, counterBufferCount,
5135 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5136 }
5137
5138 return skip;
5139}
5140
5141bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
5142 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
5143 const VkBuffer *pCounterBuffers,
5144 const VkDeviceSize *pCounterBufferOffsets) const {
5145 bool skip = false;
5146
5147 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
5148 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5149 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
5150 "%s: The firstCounterBuffer(%" PRIu32
5151 ") index is greater than or equal to "
5152 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5153 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5154 }
5155
5156 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
5157 skip |=
5158 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
5159 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
5160 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
5161 cmd_name, firstCounterBuffer, counterBufferCount,
5162 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
5163 }
5164
5165 return skip;
5166}
5167
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005168bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
5169 uint32_t firstInstance, VkBuffer counterBuffer,
5170 VkDeviceSize counterBufferOffset,
5171 uint32_t counterOffset, uint32_t vertexStride) const {
5172 bool skip = false;
5173
5174 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005175 skip |= LogError(
5176 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005177 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5178 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5179 }
5180
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005181 if ((counterOffset % 4) != 0) {
5182 // TODO - Update when header are updated
5183 skip |= LogError(commandBuffer, "UNASSIGNED-vkCmdDrawIndirectByteCountEXT-offset",
5184 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5185 }
5186
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005187 return skip;
5188}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005189
5190bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5191 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5192 const VkAllocationCallbacks *pAllocator,
5193 VkSamplerYcbcrConversion *pYcbcrConversion,
5194 const char *apiName) const {
5195 bool skip = false;
5196
5197 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07005198 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005199 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005200 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
5201 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5202 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005203 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005204 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005205 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005206
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005207#ifdef VK_USE_PLATFORM_ANDROID_KHR
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005208 const VkExternalFormatANDROID *external_format_android = lvl_find_in_chain<VkExternalFormatANDROID>(pCreateInfo);
5209 const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005210#else
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005211 const bool is_external_format = false;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005212#endif
5213
sfricke-samsung1a72f942020-07-25 12:09:18 -07005214 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005215
5216 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005217 if (!is_external_format) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005218 const VkComponentMapping components = pCreateInfo->components;
5219 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5220 if (FormatIsXChromaSubsampled(format) == true) {
5221 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5222 skip |=
5223 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005224 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5225 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005226 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005227 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005228
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005229 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5230 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5231 skip |= LogError(
5232 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5233 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5234 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5235 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5236 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005237
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005238 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5239 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5240 skip |=
5241 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005242 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5243 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005244 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005245 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005246
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005247 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5248 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5249 skip |=
5250 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005251 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5252 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005253 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005254 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005255
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005256 // If one is identity, both need to be
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005257 const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5258 const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5259 if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) {
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005260 skip |=
5261 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005262 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5263 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005264 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5265 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005266 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005267 }
5268
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005269 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5270 // Checks same VU multiple ways in order to give a more useful error message
5271 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5272 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5273 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5274 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5275 skip |= LogError(
5276 device, vuid,
5277 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5278 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5279 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5280 string_VkComponentSwizzle(components.b));
5281 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005282
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005283 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5284 // 4 channel format = no issue
5285 // 3 = no [a]
5286 // 2 = no [b,a]
5287 // 1 = no [g,b,a]
5288 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5289 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5290
5291 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5292 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5293 skip |= LogError(device, vuid,
5294 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5295 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5296 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5297 string_VkComponentSwizzle(components.b));
5298 } else if ((channels < 3) &&
5299 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5300 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5301 skip |= LogError(device, vuid,
5302 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5303 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5304 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5305 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5306 string_VkComponentSwizzle(components.b));
5307 } else if ((channels < 2) &&
5308 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5309 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5310 skip |= LogError(device, vuid,
5311 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5312 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5313 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5314 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5315 string_VkComponentSwizzle(components.b));
5316 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005317 }
5318 }
5319
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005320 return skip;
5321}
5322
5323bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5324 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5325 const VkAllocationCallbacks *pAllocator,
5326 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5327 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5328 "vkCreateSamplerYcbcrConversion");
5329}
5330
5331bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5332 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5333 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5334 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5335 "vkCreateSamplerYcbcrConversionKHR");
5336}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005337
5338bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5339 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5340 bool skip = false;
5341 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5342 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5343
5344 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005345 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5346 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5347 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5348 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5349 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005350 }
5351 return skip;
5352}
sourav parmara96ab1a2020-04-25 16:28:23 -07005353
5354bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005355 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005356 bool skip = false;
5357 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5358 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5359 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5360 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005361 const auto *acc_struct_features = lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
5362 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5363 skip |= LogError(
5364 device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584",
5365 "vkCopyAccelerationStructureToMemoryKHR: The "
5366 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5367 }
5368 skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress,
5369 "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732");
5370 if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) {
5371 skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751",
5372 "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes.");
5373 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005374 return skip;
5375}
5376
5377bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5378 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5379 bool skip = false;
5380 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5381 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5382 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5383 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5384 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005385 if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) {
5386 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740",
5387 "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.",
5388 pInfo->dst.deviceAddress);
sourav parmar83c31b12020-05-06 12:30:54 -07005389 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005390 return skip;
5391}
5392
5393bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5394 const char *api_name) const {
5395 bool skip = false;
5396 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5397 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5398 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5399 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5400 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5401 api_name);
5402 }
5403 return skip;
5404}
5405
5406bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005407 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005408 bool skip = false;
5409 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmarcd5fb182020-07-17 12:58:44 -07005410 const auto *acc_struct_features = lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
5411 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
sourav parmar83c31b12020-05-06 12:30:54 -07005412 skip |= LogError(
sourav parmarcd5fb182020-07-17 12:58:44 -07005413 device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582",
5414 "vkCopyAccelerationStructureKHR: The "
5415 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005416 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005417 return skip;
5418}
5419
5420bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5421 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5422 bool skip = false;
5423 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5424 return skip;
5425}
5426
5427bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005428 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005429 bool skip = false;
5430 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005431 skip |= LogError(device,
sourav parmarcd5fb182020-07-17 12:58:44 -07005432 "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005433 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5434 }
5435 return skip;
5436}
5437
5438bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005439 VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005440 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005441 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
sourav parmarcd5fb182020-07-17 12:58:44 -07005442 const auto *acc_struct_features = lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
5443 if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) {
5444 skip |= LogError(
5445 device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583",
5446 "vkCopyMemoryToAccelerationStructureKHR: The "
5447 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005448 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005449 skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress,
5450 "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729");
sourav parmara96ab1a2020-04-25 16:28:23 -07005451 return skip;
5452}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005453
sourav parmara96ab1a2020-04-25 16:28:23 -07005454bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5455 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5456 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005457 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
sourav parmarcd5fb182020-07-17 12:58:44 -07005458 if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) {
5459 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743",
5460 "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.",
5461 pInfo->src.deviceAddress);
5462 }
sourav parmar83c31b12020-05-06 12:30:54 -07005463 return skip;
5464}
5465bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5466 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5467 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5468 bool skip = false;
5469 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5470 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5471 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5472 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5473 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5474 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5475 }
5476 return skip;
5477}
5478bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5479 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5480 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5481 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005482 const auto *acc_structure_features =
5483 lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
5484 if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) {
5485 skip |= LogError(
5486 device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585",
5487 "vkCmdWriteAccelerationStructuresPropertiesKHR: The "
5488 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled.");
5489 }
sourav parmar83c31b12020-05-06 12:30:54 -07005490 if (dataSize < accelerationStructureCount * stride) {
5491 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5492 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5493 "accelerationStructureCount (%d) *stride(%zu).",
5494 dataSize, accelerationStructureCount, stride);
5495 }
5496 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5497 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5498 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5499 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5500 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5501 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5502 }
5503 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5504 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5505 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5506 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5507 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5508 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5509 stride);
5510 }
5511 }
5512 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5513 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5514 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5515 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5516 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5517 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5518 stride);
5519 }
5520 }
sourav parmar83c31b12020-05-06 12:30:54 -07005521 return skip;
5522}
5523bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5524 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5525 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005526 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
5527 if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) {
5528 skip |= LogError(
5529 device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606",
5530 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::"
5531 "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function.");
sourav parmar83c31b12020-05-06 12:30:54 -07005532 }
5533 return skip;
5534}
5535
5536bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
sourav parmarcd5fb182020-07-17 12:58:44 -07005537 const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5538 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable,
5539 const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5540 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable,
sourav parmar83c31b12020-05-06 12:30:54 -07005541 uint32_t width, uint32_t height, uint32_t depth) const {
5542 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005543 // RayGen
5544 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5545 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023",
5546 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005547 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005548 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5549 0) {
5550 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682",
5551 "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5552 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5553 }
5554 // Callable
5555 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5556 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694",
5557 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5558 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005559 }
5560 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5561 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5562 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005563 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5564 }
5565 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5566 0) {
5567 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693",
5568 "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5569 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005570 }
5571 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005572 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5573 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690",
5574 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5575 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005576 }
5577 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5578 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005579 "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to "
5580 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride");
sourav parmar83c31b12020-05-06 12:30:54 -07005581 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005582 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5583 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689",
5584 "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5585 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5586 }
sourav parmar83c31b12020-05-06 12:30:54 -07005587 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005588 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5589 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686",
5590 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of "
5591 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment");
sourav parmar83c31b12020-05-06 12:30:54 -07005592 }
5593 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5594 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5595 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
sourav parmarcd5fb182020-07-17 12:58:44 -07005596 "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5597 }
5598 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5599 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685",
5600 "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5601 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5602 }
5603 if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) {
5604 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629",
5605 "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to "
5606 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount");
5607 }
5608 if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) {
5609 skip |=
5610 LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626",
5611 "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] "
5612 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]");
sourav parmar83c31b12020-05-06 12:30:54 -07005613 }
5614
sourav parmarcd5fb182020-07-17 12:58:44 -07005615 if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) {
5616 skip |=
5617 LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627",
5618 "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] "
5619 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]");
5620 }
5621
5622 if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) {
5623 skip |=
5624 LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628",
5625 "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] "
5626 "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]");
sourav parmar83c31b12020-05-06 12:30:54 -07005627 }
5628 return skip;
5629}
5630
sourav parmarcd5fb182020-07-17 12:58:44 -07005631bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(
5632 VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable,
5633 const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable,
5634 const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005635 bool skip = false;
sourav parmarcd5fb182020-07-17 12:58:44 -07005636 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
5637 if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) {
5638 skip |= LogError(
5639 device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637",
5640 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect "
5641 "feature must be enabled.");
sourav parmar83c31b12020-05-06 12:30:54 -07005642 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005643 // RayGen
5644 if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) {
5645 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023",
5646 "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member");
sourav parmar83c31b12020-05-06 12:30:54 -07005647 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005648 if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5649 0) {
5650 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682",
5651 "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of "
5652 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5653 }
5654 // Callabe
5655 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5656 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694",
5657 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of "
5658 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005659 }
5660 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5661 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
sourav parmarcd5fb182020-07-17 12:58:44 -07005662 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal "
5663 "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5664 }
5665 if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) !=
5666 0) {
5667 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693",
5668 "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of "
5669 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005670 }
5671 // hitShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005672 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5673 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690",
5674 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of "
5675 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005676 }
5677 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5678 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
sourav parmarcd5fb182020-07-17 12:58:44 -07005679 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to "
5680 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
sourav parmar83c31b12020-05-06 12:30:54 -07005681 }
sourav parmarcd5fb182020-07-17 12:58:44 -07005682 if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5683 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689",
5684 "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of "
5685 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
5686 }
sourav parmar83c31b12020-05-06 12:30:54 -07005687 // missShader
sourav parmarcd5fb182020-07-17 12:58:44 -07005688 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) {
5689 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686",
5690 "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of "
5691 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005692 }
5693 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5694 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
sourav parmarcd5fb182020-07-17 12:58:44 -07005695 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to "
5696 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride.");
5697 }
5698 if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5699 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685",
5700 "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of "
5701 "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment.");
sourav parmar83c31b12020-05-06 12:30:54 -07005702 }
5703
sourav parmarcd5fb182020-07-17 12:58:44 -07005704 if (SafeModulo(indirectDeviceAddress, 4) != 0) {
5705 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634",
5706 "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4.");
sourav parmar83c31b12020-05-06 12:30:54 -07005707 }
5708 return skip;
5709}
5710bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5711 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5712 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5713 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5714 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5715 uint32_t width, uint32_t height, uint32_t depth) const {
5716 bool skip = false;
5717 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5718 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5719 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5720 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5721 }
5722 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5723 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5724 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5725 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5726 }
5727 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5728 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5729 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5730 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5731 }
5732
5733 // hitShader
5734 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5735 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5736 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5737 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5738 }
5739 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5740 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5741 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5742 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5743 }
5744 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5745 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5746 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5747 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5748 }
5749
5750 // missShader
5751 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5752 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5753 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5754 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5755 }
5756 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5757 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5758 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5759 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5760 }
5761 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5762 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5763 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5764 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5765 }
5766
5767 // raygenShader
5768 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5769 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5770 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005771 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5772 }
5773 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5774 skip |=
5775 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5776 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5777 }
5778 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5779 skip |=
5780 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5781 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5782 }
5783 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5784 skip |=
5785 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5786 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005787 }
5788 return skip;
5789}
5790
sourav parmar83c31b12020-05-06 12:30:54 -07005791bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
sourav parmarcd5fb182020-07-17 12:58:44 -07005792 VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo,
5793 VkAccelerationStructureCompatibilityKHR *pCompatibility) const {
sourav parmar83c31b12020-05-06 12:30:54 -07005794 bool skip = false;
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005795 const auto *ray_query_features = lvl_find_in_chain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
sourav parmarcd5fb182020-07-17 12:58:44 -07005796 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
Nathaniel Cesarioce9b4812020-12-17 08:55:28 -07005797 if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) ||
5798 (raytracing_features && !raytracing_features->rayTracingPipeline))) {
sourav parmarcd5fb182020-07-17 12:58:44 -07005799 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661",
sourav parmar83c31b12020-05-06 12:30:54 -07005800 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5801 }
5802 return skip;
5803}
5804
Piers Daniell39842ee2020-07-10 16:42:33 -06005805bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5806 const VkViewport *pViewports) const {
5807 bool skip = false;
5808
5809 if (!physical_device_features.multiViewport) {
5810 if (viewportCount != 1) {
5811 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5812 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5813 ") is not 1.",
5814 viewportCount);
5815 }
5816 } else { // multiViewport enabled
5817 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5818 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5819 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5820 ") must "
5821 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5822 viewportCount, device_limits.maxViewports);
5823 }
5824 }
5825
5826 if (pViewports) {
5827 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5828 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5829 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5830 skip |= manual_PreCallValidateViewport(
5831 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5832 }
5833 }
5834
5835 return skip;
5836}
5837
5838bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5839 const VkRect2D *pScissors) const {
5840 bool skip = false;
5841
5842 if (!physical_device_features.multiViewport) {
5843 if (scissorCount != 1) {
5844 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5845 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5846 ") must "
5847 "be 1 when the multiViewport feature is disabled.",
5848 scissorCount);
5849 }
5850 } else { // multiViewport enabled
5851 if (scissorCount == 0) {
5852 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5853 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5854 ") must "
5855 "be great than zero.",
5856 scissorCount);
5857 } else if (scissorCount > device_limits.maxViewports) {
5858 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5859 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5860 ") must "
5861 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5862 scissorCount, device_limits.maxViewports);
5863 }
5864 }
5865
5866 if (pScissors) {
5867 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5868 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5869
5870 if (scissor.offset.x < 0) {
5871 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5872 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5873 scissor.offset.x);
5874 }
5875
5876 if (scissor.offset.y < 0) {
5877 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5878 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5879 scissor.offset.y);
5880 }
5881
5882 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5883 if (x_sum > INT32_MAX) {
5884 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5885 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5886 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5887 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5888 }
5889
5890 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5891 if (y_sum > INT32_MAX) {
5892 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5893 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5894 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5895 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5896 }
5897 }
5898 }
5899
5900 return skip;
5901}
5902
5903bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5904 uint32_t bindingCount, const VkBuffer *pBuffers,
5905 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5906 const VkDeviceSize *pStrides) const {
5907 bool skip = false;
5908 if (firstBinding >= device_limits.maxVertexInputBindings) {
5909 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
5910 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
5911 firstBinding, device_limits.maxVertexInputBindings);
5912 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5913 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
5914 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5915 "maxVertexInputBindings (%u)",
5916 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5917 }
5918
5919 for (uint32_t i = 0; i < bindingCount; ++i) {
5920 if (pBuffers[i] == VK_NULL_HANDLE) {
5921 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
5922 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5923 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
5924 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5925 } else {
5926 if (pOffsets[i] != 0) {
5927 skip |=
5928 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
5929 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5930 }
5931 }
5932 }
5933 if (pStrides) {
5934 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
5935 skip |=
5936 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
5937 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
5938 pStrides[i], device_limits.maxVertexInputBindingStride);
5939 }
5940 }
5941 }
5942
5943 return skip;
5944}
sourav parmarcd5fb182020-07-17 12:58:44 -07005945
5946bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR(
5947 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const {
5948 bool skip = false;
5949 for (uint32_t i = 0; i < infoCount; ++i) {
5950 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) {
5951 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654",
5952 "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name);
5953 }
5954 if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
5955 pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
5956 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796",
5957 "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set,"
5958 "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.",
5959 api_name);
5960 }
5961 if (pInfos[i].pGeometries && pInfos[i].ppGeometries) {
5962 skip |=
5963 LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788",
5964 "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name);
5965 }
5966 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) {
5967 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790",
5968 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name);
5969 }
5970 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
5971 pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) {
5972 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793",
5973 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be"
5974 " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount",
5975 api_name);
5976 }
5977 if (pInfos[i].pGeometries) {
5978 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
5979 skip |= validate_ranged_enum(
5980 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}),
5981 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType,
5982 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
5983 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
5984 if (pInfos[i].pGeometries[j].geometry.triangles.maxVertex <= 0) {
5985 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655",
5986 "(%s): maxVertex must be greater than 0", api_name);
5987 }
5988 skip |= validate_struct_type(
5989 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}),
5990 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
5991 &(pInfos[i].pGeometries[j].geometry.triangles),
5992 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
5993 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
5994 skip |= validate_struct_pnext(
5995 api_name,
5996 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
5997 NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
5998 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
5999 skip |=
6000 validate_ranged_enum(api_name,
6001 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat",
6002 ParameterName::IndexVector{i, j}),
6003 "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat,
6004 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6005 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6006 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6007 &pInfos[i].pGeometries[j].geometry.triangles,
6008 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6009 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6010 skip |= validate_ranged_enum(
6011 api_name,
6012 ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}),
6013 "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType,
6014 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6015
6016 if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) {
6017 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6018 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6019 }
6020 if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6021 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6022 pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6023 skip |=
6024 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6025 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6026 api_name);
6027 }
6028 }
6029 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6030 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6031 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6032 &pInfos[i].pGeometries[j].geometry.instances,
6033 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6034 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6035 skip |= validate_struct_type(
6036 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}),
6037 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6038 &(pInfos[i].pGeometries[j].geometry.instances),
6039 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6040 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6041 skip |= validate_struct_pnext(
6042 api_name,
6043 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6044 NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6045 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6046
6047 skip |= validate_bool32(api_name,
6048 ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers",
6049 ParameterName::IndexVector{i, j}),
6050 pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers);
6051 }
6052 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6053 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6054 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6055 &pInfos[i].pGeometries[j].geometry.aabbs,
6056 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6057 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6058 skip |= validate_struct_type(
6059 api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}),
6060 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6061 &(pInfos[i].pGeometries[j].geometry.aabbs),
6062 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6063 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6064 skip |= validate_struct_pnext(
6065 api_name,
6066 ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6067 pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6068 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6069 if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) {
6070 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6071 "(%s):stride must be less than or equal to 2^32-1", api_name);
6072 }
6073 }
6074 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6075 pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6076 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6077 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6078 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6079 api_name);
6080 }
6081 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6082 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6083 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6084 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6085 "of elements of"
6086 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6087 api_name);
6088 }
6089 if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) {
6090 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6091 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6092 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6093 api_name);
6094 }
6095 }
6096 }
6097 }
6098 if (pInfos[i].ppGeometries != NULL) {
6099 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6100 skip |= validate_ranged_enum(
6101 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}),
6102 "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType,
6103 "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter");
6104 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6105 if (pInfos[i].ppGeometries[j]->geometry.triangles.maxVertex <= 0) {
6106 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655",
6107 "(%s): maxVertex must be greater than 0", api_name);
6108 }
6109 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles",
6110 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6111 &pInfos[i].ppGeometries[j]->geometry.triangles,
6112 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true,
6113 "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined);
6114 skip |= validate_struct_type(
6115 api_name,
6116 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}),
6117 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR",
6118 &(pInfos[i].ppGeometries[j]->geometry.triangles),
6119 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined,
6120 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType");
6121 skip |= validate_struct_pnext(
6122 api_name,
6123 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}),
6124 NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6125 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined);
6126 skip |= validate_ranged_enum(api_name,
6127 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat",
6128 ParameterName::IndexVector{i, j}),
6129 "VkFormat", AllVkFormatEnums,
6130 pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat,
6131 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter");
6132 skip |= validate_ranged_enum(api_name,
6133 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType",
6134 ParameterName::IndexVector{i, j}),
6135 "VkIndexType", AllVkIndexTypeEnums,
6136 pInfos[i].ppGeometries[j]->geometry.triangles.indexType,
6137 "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter");
6138 if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) {
6139 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819",
6140 "(%s):vertexStride must be less than or equal to 2^32-1", api_name);
6141 }
6142 if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 &&
6143 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 &&
6144 pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) {
6145 skip |=
6146 LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798",
6147 "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR",
6148 api_name);
6149 }
6150 }
6151 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6152 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances",
6153 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6154 &pInfos[i].ppGeometries[j]->geometry.instances,
6155 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true,
6156 "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined);
6157 skip |= validate_struct_type(
6158 api_name,
6159 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}),
6160 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR",
6161 &(pInfos[i].ppGeometries[j]->geometry.instances),
6162 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined,
6163 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType");
6164 skip |= validate_struct_pnext(
6165 api_name,
6166 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}),
6167 NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6168 "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined);
6169 skip |= validate_bool32(api_name,
6170 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers",
6171 ParameterName::IndexVector{i, j}),
6172 pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers);
6173 }
6174 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6175 skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs",
6176 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6177 &pInfos[i].ppGeometries[j]->geometry.aabbs,
6178 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true,
6179 "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined);
6180 skip |= validate_struct_type(
6181 api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}),
6182 "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR",
6183 &(pInfos[i].ppGeometries[j]->geometry.aabbs),
6184 VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined,
6185 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType");
6186 skip |= validate_struct_pnext(
6187 api_name,
6188 ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL,
6189 pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion,
6190 "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined);
6191 if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) {
6192 skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820",
6193 "(%s):stride must be less than or equal to 2^32-1", api_name);
6194 }
6195 }
6196 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR &&
6197 pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6198 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789",
6199 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member"
6200 " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6201 api_name);
6202 }
6203 if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) {
6204 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6205 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791",
6206 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member "
6207 "of elements of"
6208 " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
6209 api_name);
6210 }
6211 if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) {
6212 skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792",
6213 "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType"
6214 " member of each geometry in either pGeometries or ppGeometries must be the same.",
6215 api_name);
6216 }
6217 }
6218 }
6219 }
6220 }
6221 return skip;
6222}
6223bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR(
6224 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6225 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6226 bool skip = false;
6227 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR");
6228 for (uint32_t i = 0; i < infoCount; ++i) {
6229 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6230 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6231 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710",
6232 "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its "
6233 "scratchData.deviceAddress member must be a multiple of "
6234 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6235 }
6236 for (uint32_t k = 0; k < infoCount; ++k) {
6237 if (i == k) continue;
6238 bool found = false;
6239 if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6240 skip |= LogError(
6241 device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6242 "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must "
6243 "not be "
6244 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6245 i, k);
6246 found = true;
6247 }
6248 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6249 skip |= LogError(
6250 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403",
6251 "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must "
6252 "not be "
6253 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6254 i, k);
6255 found = true;
6256 }
6257 if (found) break;
6258 }
6259 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6260 if (pInfos[i].pGeometries) {
6261 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6262 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6263 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6264 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6265 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6266 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6267 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6268 }
6269 } else {
6270 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6271 skip |=
6272 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6273 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6274 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6275 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6276 }
6277 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006278 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006279 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6280 skip |= LogError(
6281 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6282 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6283 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6284 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006285 } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6286 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006287 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6288 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6289 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6290 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6291 }
6292 }
6293 } else if (pInfos[i].ppGeometries) {
6294 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6295 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6296 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6297 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716",
6298 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6299 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6300 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6301 }
6302 } else {
6303 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6304 skip |=
6305 LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715",
6306 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6307 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6308 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6309 }
6310 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006311 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006312 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6313 skip |= LogError(
6314 device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714",
6315 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a "
6316 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6317 }
Ricardo Garcia2ba3da82020-12-02 11:27:53 +01006318 } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6319 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) {
sourav parmarcd5fb182020-07-17 12:58:44 -07006320 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810",
6321 "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries "
6322 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6323 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6324 }
6325 }
6326 }
6327 }
6328 }
6329 return skip;
6330}
6331
6332bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR(
6333 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6334 const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides,
6335 const uint32_t *const *ppMaxPrimitiveCounts) const {
6336 bool skip = false;
6337 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR");
6338 const auto *ray_tracing_acceleration_structure_features =
6339 lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
6340 if (!ray_tracing_acceleration_structure_features ||
6341 ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) {
6342 skip |= LogError(
6343 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650",
6344 "vkCmdBuildAccelerationStructuresIndirectKHR: The "
6345 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled.");
6346 }
6347 for (uint32_t i = 0; i < infoCount; ++i) {
6348 if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) {
6349 if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) {
6350 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666",
6351 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is "
6352 "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be "
6353 "VK_NULL_HANDLE.");
6354 }
6355 }
6356 if (SafeModulo(pInfos[i].scratchData.deviceAddress,
6357 phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) {
6358 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710",
6359 "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its "
6360 "scratchData.deviceAddress member must be a multiple of "
6361 "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment.");
6362 }
6363 for (uint32_t k = 0; k < infoCount; ++k) {
6364 if (i == k) continue;
6365 if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) {
6366 skip |=
6367 LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403",
6368 "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) "
6369 "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of "
6370 "any other element [%d) of pInfos.",
6371 i, k);
6372 break;
6373 }
6374 }
6375 for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) {
6376 if (pInfos[i].pGeometries) {
6377 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6378 if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) {
6379 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6380 skip |= LogError(
6381 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6382 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6383 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6384 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6385 }
6386 } else {
6387 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) {
6388 skip |= LogError(
6389 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6390 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6391 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6392 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6393 }
6394 }
6395 }
6396 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6397 if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) {
6398 skip |= LogError(
6399 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6400 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6401 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6402 }
6403 }
6404 if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6405 if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) {
6406 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6407 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6408 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6409 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6410 }
6411 }
6412 } else if (pInfos[i].ppGeometries) {
6413 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
6414 if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) {
6415 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6416 skip |= LogError(
6417 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716",
6418 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6419 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is "
6420 "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes.");
6421 }
6422 } else {
6423 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) {
6424 skip |= LogError(
6425 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715",
6426 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6427 "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, "
6428 "geometry.data->deviceAddress must be aligned to 16 bytes.");
6429 }
6430 }
6431 }
6432 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) {
6433 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) {
6434 skip |= LogError(
6435 device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714",
6436 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a "
6437 "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes.");
6438 }
6439 }
6440 if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
6441 if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) {
6442 skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810",
6443 "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries "
6444 "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, "
6445 "geometry.transformData->deviceAddress must be aligned to 16 bytes.");
6446 }
6447 }
6448 }
6449 }
6450 }
6451 return skip;
6452}
6453
6454bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR(
6455 VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount,
6456 const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
6457 const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const {
6458 bool skip = false;
6459 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR");
6460 const auto *ray_tracing_acceleration_structure_features =
6461 lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext);
6462 if (!ray_tracing_acceleration_structure_features ||
6463 ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) {
6464 skip |=
6465 LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581",
6466 "vkBuildAccelerationStructuresKHR: The "
6467 "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled");
6468 }
6469 for (uint32_t i = 0; i < infoCount; ++i) {
6470 for (uint32_t j = 0; j < infoCount; ++j) {
6471 if (i == j) continue;
6472 bool found = false;
6473 if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6474 skip |= LogError(
6475 device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698",
6476 "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must "
6477 "not be "
6478 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6479 i, j);
6480 found = true;
6481 }
6482 if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) {
6483 skip |= LogError(
6484 device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403",
6485 "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must "
6486 "not be "
6487 "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.",
6488 i, j);
6489 found = true;
6490 }
6491 if (found) break;
6492 }
6493 }
6494 return skip;
6495}
6496
6497bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR(
6498 VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo,
6499 const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const {
6500 bool skip = false;
6501 skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR");
6502 const auto *ray_tracing_pipeline_features =
6503 lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext);
6504 const auto *ray_query_features = lvl_find_in_chain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext);
6505 if (!(ray_tracing_pipeline_features || ray_query_features) ||
6506 ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) ||
6507 (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) {
6508 skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617",
6509 "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled");
6510 }
6511 return skip;
6512}