blob: 07a424cb9f42b65c396b7dfd57a9cb1cb0672f45 [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
Mark Lobodzinskid4950072017-08-01 13:02:20 -060028static const int MaxParamCheckerStringLength = 256;
29
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 Lobodzinskibf599b92018-12-31 12:15:55 -070036bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid,
Jeff Bolz46c0ea02019-10-09 13:06:29 -050037 const char *validateString) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -060038 bool skip = false;
39
40 VkStringErrorFlags result = vk_string_validate(MaxParamCheckerStringLength, validateString);
41
42 if (result == VK_STRING_ERROR_NONE) {
43 return skip;
44 } else if (result & VK_STRING_ERROR_LENGTH) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070045 skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(),
46 MaxParamCheckerStringLength);
Mark Lobodzinskid4950072017-08-01 13:02:20 -060047 } else if (result & VK_STRING_ERROR_BAD_DATA) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070048 skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName,
49 stringName.get_name().c_str());
Mark Lobodzinskid4950072017-08-01 13:02:20 -060050 }
51 return skip;
52}
53
Jeff Bolz46c0ea02019-10-09 13:06:29 -050054bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const {
John Zulauf620755c2018-04-16 11:00:43 -060055 bool skip = false;
56 uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0);
57 if (api_version_nopatch != effective_api_version) {
sfricke-samsung6aec21b2020-11-01 07:49:43 -080058 if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) {
59 skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070060 "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
61 "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
62 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060063 } else {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -070064 skip |= LogWarning(instance, kVUIDUndefined,
65 "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). "
66 "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".",
67 api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version));
John Zulauf620755c2018-04-16 11:00:43 -060068 }
69 }
70 return skip;
71}
72
Jeff Bolz46c0ea02019-10-09 13:06:29 -050073bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const {
John Zulauf620755c2018-04-16 11:00:43 -060074 bool skip = false;
Mark Lobodzinski05cce202019-08-27 10:28:37 -060075 // Create and use a local instance extension object, as an actual instance has not been created yet
76 uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0);
77 InstanceExtensions local_instance_extensions;
78 local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo);
79
John Zulauf620755c2018-04-16 11:00:43 -060080 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
Mark Lobodzinski05cce202019-08-27 10:28:37 -060081 skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388",
82 "instance", pCreateInfo->ppEnabledExtensionNames[i]);
John Zulauf620755c2018-04-16 11:00:43 -060083 }
84
85 return skip;
86}
87
Mark Lobodzinskibece6c12020-08-27 15:34:02 -060088bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const {
89 if (instance_extensions.vk_khr_get_physical_device_properties_2) {
90 // Struct is legal IF it's supported
91 const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device);
92 if (dev_exts_enumerated == device_extensions_enumerated.end()) return true;
93 auto enum_iter = dev_exts_enumerated->second.find(ext_name);
94 if (enum_iter != dev_exts_enumerated->second.cend()) {
95 return true;
96 }
97 }
98 return false;
99}
100
Tony-LunarG866843d2020-05-13 11:22:42 -0600101bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo,
102 const VkValidationFeaturesEXT *validation_features) const {
103 bool skip = false;
104 bool debug_printf = false;
105 bool gpu_assisted = false;
106 bool reserve_slot = false;
107 for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) {
108 switch (validation_features->pEnabledValidationFeatures[i]) {
109 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT:
110 gpu_assisted = true;
111 break;
112
113 case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT:
114 debug_printf = true;
115 break;
116
117 case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT:
118 reserve_slot = true;
119 break;
120
121 default:
122 break;
123 }
124 }
125 if (reserve_slot && !gpu_assisted) {
126 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967",
127 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, "
128 "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures.");
129 }
130 if (gpu_assisted && debug_printf) {
131 skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968",
132 "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, "
133 "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures.");
134 }
135
136 return skip;
137}
138
John Zulauf620755c2018-04-16 11:00:43 -0600139template <typename ExtensionState>
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700140ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) {
141 if (!extension_name) return kNotEnabled; // null strings specify nothing
John Zulauf620755c2018-04-16 11:00:43 -0600142 auto info = ExtensionState::get_info(extension_name);
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700143 ExtEnabled state =
144 info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct
John Zulauf620755c2018-04-16 11:00:43 -0600145 return state;
146}
147
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700148bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500149 const VkAllocationCallbacks *pAllocator,
150 VkInstance *pInstance) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700151 bool skip = false;
152 // Note: From the spec--
153 // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing
154 // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0)
155 uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion)
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700156 ? pCreateInfo->pApplicationInfo->apiVersion
157 : VK_API_VERSION_1_0;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700158 skip |= validate_api_version(local_api_version, api_version);
159 skip |= validate_instance_extensions(pCreateInfo);
Tony-LunarG866843d2020-05-13 11:22:42 -0600160 const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext);
161 if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features);
162
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700163 return skip;
164}
165
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700166void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700167 const VkAllocationCallbacks *pAllocator, VkInstance *pInstance,
168 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700169 auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map);
170 // Copy extension data into local object
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700171 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700172 this->instance_extensions = instance_data->instance_extensions;
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600173
174 uint32_t pdev_count = 0;
175 DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, nullptr);
176 std::vector<VkPhysicalDevice> physical_devices;
177 physical_devices.resize(pdev_count);
178 DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, physical_devices.data());
179
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600180 for (uint32_t i = 0; i < physical_devices.size(); i++) {
181 auto phys_dev_props = new VkPhysicalDeviceProperties;
182 DispatchGetPhysicalDeviceProperties(physical_devices[i], phys_dev_props);
183 physical_device_properties_map[physical_devices[i]] = phys_dev_props;
Mark Lobodzinskibece6c12020-08-27 15:34:02 -0600184
185 // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state
186 uint32_t ext_count = 0;
187 std::unordered_set<std::string> dev_exts_enumerated{};
188 std::vector<VkExtensionProperties> ext_props{};
189 instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, nullptr);
190 ext_props.resize(ext_count);
191 instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, ext_props.data());
192 for (uint32_t j = 0; j < ext_count; j++) {
193 dev_exts_enumerated.insert(ext_props[j].extensionName);
194 }
195 device_extensions_enumerated[physical_devices[i]] = std::move(dev_exts_enumerated);
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600196 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700197}
198
Mark Lobodzinski2e40a132020-08-10 14:51:41 -0600199void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) {
200 for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) {
201 delete (it->second);
202 it = physical_device_properties_map.erase(it);
203 }
204};
205
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700206void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700207 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700208 auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map);
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -0700209 if (result != VK_SUCCESS) return;
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700210 ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation);
211 StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700212
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700213 // Parmeter validation also uses extension data
214 stateless_validation->device_extensions = this->device_extensions;
215
216 VkPhysicalDeviceProperties device_properties = {};
217 // Need to get instance and do a getlayerdata call...
Tony-LunarG152a88b2019-03-20 15:42:24 -0600218 DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700219 memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits));
220
221 if (device_extensions.vk_nv_shading_rate_image) {
222 // Get the needed shading rate image limits
223 auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>();
224 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&shading_rate_image_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600225 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700226 phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props;
227 }
228
229 if (device_extensions.vk_nv_mesh_shader) {
230 // Get the needed mesh shader limits
231 auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>();
232 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&mesh_shader_props);
Tony-LunarG152a88b2019-03-20 15:42:24 -0600233 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700234 phys_dev_ext_props.mesh_shader_props = mesh_shader_props;
235 }
236
Jason Macnak5c954952019-07-09 15:46:12 -0700237 if (device_extensions.vk_nv_ray_tracing) {
238 // Get the needed ray tracing limits
239 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>();
240 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
241 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
Jeff Bolz443c2ca2020-03-19 12:11:51 -0500242 phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props;
243 }
244
245 if (device_extensions.vk_khr_ray_tracing) {
246 // Get the needed ray tracing limits
247 auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesKHR>();
248 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&ray_tracing_props);
249 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
250 phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props;
Jason Macnak5c954952019-07-09 15:46:12 -0700251 }
252
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -0700253 if (device_extensions.vk_ext_transform_feedback) {
254 // Get the needed transform feedback limits
255 auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>();
256 auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2KHR>(&transform_feedback_props);
257 DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2);
258 phys_dev_ext_props.transform_feedback_props = transform_feedback_props;
259 }
260
Jasper St. Pierrea49b4be2019-02-05 17:48:57 -0800261 stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props;
262
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700263 // Save app-enabled features in this device's validation object
264 // The enabled features can come from either pEnabledFeatures, or from the pNext chain
Petr Kraus715bcc72019-08-15 17:17:33 +0200265 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
266 safe_VkPhysicalDeviceFeatures2 tmp_features2_state;
267 tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2;
268 if (features2) {
269 tmp_features2_state.features = features2->features;
270 } else if (pCreateInfo->pEnabledFeatures) {
271 tmp_features2_state.features = *pCreateInfo->pEnabledFeatures;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700272 } else {
Petr Kraus715bcc72019-08-15 17:17:33 +0200273 tmp_features2_state.features = {};
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700274 }
Petr Kraus715bcc72019-08-15 17:17:33 +0200275 // Use pCreateInfo->pNext to get full chain
Tony-LunarG6c3c5452019-12-13 10:37:38 -0700276 stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext);
Petr Kraus715bcc72019-08-15 17:17:33 +0200277 stateless_validation->physical_device_features2 = tmp_features2_state;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700278}
279
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700280bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500281 const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600282 bool skip = false;
283
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200284 for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) {
285 skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames",
286 "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600287 }
288
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200289 for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
290 skip |=
291 validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames",
292 "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]);
293 skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device",
294 pCreateInfo->ppEnabledExtensionNames[i]);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600295 }
296
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200297 {
Tony-LunarG2ec96bb2019-11-26 13:43:02 -0700298 bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME));
299 bool negative_viewport =
300 IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME));
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200301 if (maint1 && negative_viewport) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700302 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374",
303 "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and "
304 "VK_AMD_negative_viewport_height.");
Petr Kraus6c4bdce2019-08-27 17:35:01 +0200305 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600306 }
307
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600308 {
309 bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
310 bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME));
311 if (khr_bda && ext_bda) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700312 skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328",
313 "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and "
314 "VK_EXT_buffer_device_address.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -0600315 }
316 }
317
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600318 if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) {
319 // Check for get_physical_device_properties2 struct
John Zulaufde972ac2017-10-26 12:07:05 -0600320 const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2KHR>(pCreateInfo->pNext);
321 if (features2) {
322 // Cannot include VkPhysicalDeviceFeatures2KHR and have non-null pEnabledFeatures
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700323 skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700324 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2KHR struct when "
325 "pCreateInfo->pEnabledFeatures is non-NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600326 }
327 }
328
Locke77fad1c2019-04-16 13:09:03 -0600329 auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext);
Jeff Bolz165818a2020-05-08 11:19:03 -0500330 const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures;
331 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext);
332 if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) {
333 skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000",
334 "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled.");
335 }
sourav parmara24fb7b2020-05-26 10:50:04 -0700336 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(pCreateInfo->pNext);
337 if (raytracing_features && raytracing_features->rayTracingShaderGroupHandleCaptureReplayMixed &&
338 !raytracing_features->rayTracingShaderGroupHandleCaptureReplay) {
339 skip |= LogError(device, "VUID-VkPhysicalDeviceRayTracingFeaturesKHR-rayTracingShaderGroupHandleCaptureReplayMixed-03348",
340 "If rayTracingShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingShaderGroupHandleCaptureReplay "
341 "must also be VK_TRUE.");
342 }
Locke77fad1c2019-04-16 13:09:03 -0600343 auto vertex_attribute_divisor_features =
344 lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext);
Mark Lobodzinski3e66ae82020-08-12 16:27:29 -0600345 if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) {
346 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
347 "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT "
348 "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device.");
Locke77fad1c2019-04-16 13:09:03 -0600349 }
350
Tony-LunarG28017bc2020-01-23 14:40:25 -0700351 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext);
352 if (vulkan_11_features) {
353 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
354 while (current) {
355 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES ||
356 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES ||
357 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES ||
358 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES ||
359 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES ||
360 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700361 skip |= LogError(
362 instance, "VUID-VkDeviceCreateInfo-pNext-02829",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700363 "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a "
364 "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, "
365 "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, "
366 "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure");
367 break;
368 }
369 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
370 }
371 }
372
373 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext);
374 if (vulkan_12_features) {
375 const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext);
376 while (current) {
377 if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES ||
378 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES ||
379 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES ||
380 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES ||
381 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES ||
382 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES ||
383 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES ||
384 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES ||
385 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES ||
386 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES ||
387 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES ||
388 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES ||
389 current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700390 skip |= LogError(
391 instance, "VUID-VkDeviceCreateInfo-pNext-02830",
Tony-LunarG28017bc2020-01-23 14:40:25 -0700392 "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a "
393 "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, "
394 "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, "
395 "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, "
396 "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, "
397 "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, "
398 "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or "
399 "VkPhysicalDeviceVulkanMemoryModelFeatures structure");
400 break;
401 }
402 current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext);
403 }
sfricke-samsungabab4632020-05-04 06:51:46 -0700404 // Check features are enabled if matching extension is passed in as well
405 for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) {
406 const char *extension = pCreateInfo->ppEnabledExtensionNames[i];
407 if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
408 (vulkan_12_features->drawIndirectCount == VK_FALSE)) {
409 skip |= LogError(
410 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831",
411 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.",
412 VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME);
413 }
414 if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
415 (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) {
416 skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832",
417 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge "
418 "is not VK_TRUE.",
419 VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME);
420 }
421 if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
422 (vulkan_12_features->descriptorIndexing == VK_FALSE)) {
423 skip |= LogError(
424 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833",
425 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.",
426 VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME);
427 }
428 if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
429 (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) {
430 skip |= LogError(
431 instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834",
432 "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.",
433 VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME);
434 }
435 if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) &&
436 ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) ||
437 (vulkan_12_features->shaderOutputLayer == VK_FALSE))) {
438 skip |=
439 LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835",
440 "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex "
441 "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.",
442 VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME);
443 }
444 }
Tony-LunarG28017bc2020-01-23 14:40:25 -0700445 }
446
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600447 // Validate pCreateInfo->pQueueCreateInfos
448 if (pCreateInfo->pQueueCreateInfos) {
449 std::unordered_set<uint32_t> set;
450
451 for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) {
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700452 const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i];
453 const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600454 if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700455 skip |=
456 LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381",
457 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32
458 "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family "
459 "index value.",
460 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600461 } else if (set.count(requested_queue_family)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700462 skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372",
463 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32
464 ") is not unique within pCreateInfo->pQueueCreateInfos array.",
465 i, requested_queue_family);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600466 } else {
467 set.insert(requested_queue_family);
468 }
469
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700470 if (queue_create_info.pQueuePriorities != nullptr) {
471 for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) {
472 const float queue_priority = queue_create_info.pQueuePriorities[j];
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600473 if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700474 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383",
475 "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32
476 "] (=%f) is not between 0 and 1 (inclusive).",
477 i, j, queue_priority);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600478 }
479 }
480 }
sfricke-samsung590ae1e2020-04-25 01:18:05 -0700481
482 // Need to know if protectedMemory feature is passed in preCall to creating the device
483 VkBool32 protectedMemory = VK_FALSE;
484 const VkPhysicalDeviceProtectedMemoryFeatures *protected_features =
485 lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext);
486 if (protected_features) {
487 protectedMemory = protected_features->protectedMemory;
488 } else if (vulkan_11_features) {
489 protectedMemory = vulkan_11_features->protectedMemory;
490 }
491 if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protectedMemory == VK_FALSE)) {
492 skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861",
493 "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the "
494 "protectedMemory feature being set as well.");
495 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600496 }
497 }
498
sfricke-samsung30a57412020-05-15 21:14:54 -0700499 // feature dependencies for VK_KHR_variable_pointers
500 const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext);
501 VkBool32 variablePointers = VK_FALSE;
502 VkBool32 variablePointersStorageBuffer = VK_FALSE;
503 if (vulkan_11_features) {
504 variablePointers = vulkan_11_features->variablePointers;
505 variablePointersStorageBuffer = vulkan_11_features->variablePointersStorageBuffer;
506 } else if (variable_pointers_features) {
507 variablePointers = variable_pointers_features->variablePointers;
508 variablePointersStorageBuffer = variable_pointers_features->variablePointersStorageBuffer;
509 }
510 if ((variablePointers == VK_TRUE) && (variablePointersStorageBuffer == VK_FALSE)) {
511 skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431",
512 "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE");
513 }
514
sfricke-samsungfd76c342020-05-29 23:13:43 -0700515 // feature dependencies for VK_KHR_multiview
516 const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext);
517 VkBool32 multiview = VK_FALSE;
518 VkBool32 multiviewGeometryShader = VK_FALSE;
519 VkBool32 multiviewTessellationShader = VK_FALSE;
520 if (vulkan_11_features) {
521 multiview = vulkan_11_features->multiview;
522 multiviewGeometryShader = vulkan_11_features->multiviewGeometryShader;
523 multiviewTessellationShader = vulkan_11_features->multiviewTessellationShader;
524 } else if (multiview_features) {
525 multiview = multiview_features->multiview;
526 multiviewGeometryShader = multiview_features->multiviewGeometryShader;
527 multiviewTessellationShader = multiview_features->multiviewTessellationShader;
528 }
529 if ((multiview == VK_FALSE) && (multiviewGeometryShader == VK_TRUE)) {
530 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580",
531 "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE");
532 }
533 if ((multiview == VK_FALSE) && (multiviewTessellationShader == VK_TRUE)) {
534 skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581",
535 "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE");
536 }
537
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600538 return skip;
539}
540
Jeff Bolz46c0ea02019-10-09 13:06:29 -0500541bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700542 if (!flag) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700543 return LogError(device, kVUID_PVError_ExtensionNotEnabled,
544 "%s() called even though the %s extension was not enabled for this VkDevice.", function_name,
545 extension_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600546 }
547
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700548 return false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600549}
550
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700551bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500552 const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const {
Petr Krause91f7a12017-12-14 20:57:36 +0100553 bool skip = false;
554
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600555 if (pCreateInfo != nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700556 skip |=
557 ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600558
559 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
560 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
561 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
562 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700563 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914",
564 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
565 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600566 }
567
568 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
569 // queueFamilyIndexCount uint32_t values
570 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700571 skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913",
572 "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
573 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
574 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600575 }
576 }
577
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700578 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
579 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915",
580 "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the "
581 "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set.");
582 }
583
584 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) {
585 skip |=
586 LogError(device, "VUID-VkBufferCreateInfo-flags-00916",
587 "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with "
588 "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set.");
589 }
590
591 if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
592 skip |=
593 LogError(device, "VUID-VkBufferCreateInfo-flags-00917",
594 "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with "
595 "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set.");
596 }
597
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600598 // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain
599 // VK_BUFFER_CREATE_SPARSE_BINDING_BIT
600 if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
601 ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700602 skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918",
603 "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or "
604 "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600605 }
606 }
607
608 return skip;
609}
610
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700611bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -0500612 const VkAllocationCallbacks *pAllocator, VkImage *pImage) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600613 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600614
615 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600616 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
617 if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) {
618 // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
619 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700620 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942",
621 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
622 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600623 }
624
625 // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
626 // queueFamilyIndexCount uint32_t values
627 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700628 skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941",
629 "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, "
630 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
631 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600632 }
633 }
634
Dave Houlton413a6782018-05-22 13:01:54 -0600635 skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700636 "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600637 skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700638 "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600639 skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700640 "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600641
Dave Houlton413a6782018-05-22 13:01:54 -0600642 skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700643 "vkCreateImage");
Dave Houlton413a6782018-05-22 13:01:54 -0600644 skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700645 "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600646
Dave Houlton130c0212018-01-29 13:39:56 -0700647 // InitialLayout must be PREINITIALIZED or UNDEFINED
Dave Houltone19e20d2018-02-02 16:32:41 -0700648 if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) &&
649 (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700650 skip |= LogError(
651 device, "VUID-VkImageCreateInfo-initialLayout-00993",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -0600652 "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.",
653 string_VkImageLayout(pCreateInfo->initialLayout));
Dave Houlton130c0212018-01-29 13:39:56 -0700654 }
655
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600656 // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1
Petr Kraus3ac9e812018-03-13 12:31:08 +0100657 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) &&
658 ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700659 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956",
660 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and "
661 "pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600662 }
663
664 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) {
Petr Kraus3f433212018-03-13 12:31:27 +0100665 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
666 if (pCreateInfo->extent.width != pCreateInfo->extent.height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700667 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
668 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
669 "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32
670 ") are not equal.",
671 pCreateInfo->extent.width, pCreateInfo->extent.height);
Petr Kraus3f433212018-03-13 12:31:27 +0100672 }
673
674 if (pCreateInfo->arrayLayers < 6) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700675 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954",
676 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but "
677 "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.",
678 pCreateInfo->arrayLayers);
Petr Kraus3f433212018-03-13 12:31:27 +0100679 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600680 }
681
682 if (pCreateInfo->extent.depth != 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700683 skip |= LogError(
684 device, "VUID-VkImageCreateInfo-imageType-00957",
685 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600686 }
687 }
688
Dave Houlton130c0212018-01-29 13:39:56 -0700689 // 3D image may have only 1 layer
690 if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700691 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961",
692 "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1.");
Dave Houlton130c0212018-01-29 13:39:56 -0700693 }
694
695 // If multi-sample, validate type, usage, tiling and mip levels.
696 if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) &&
697 ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) ||
Shannon McPhersona886c2a2018-10-12 14:38:20 -0600698 (pCreateInfo->mipLevels != 1) || (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700699 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257",
700 "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips.");
Dave Houlton130c0212018-01-29 13:39:56 -0700701 }
702
703 if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) {
704 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT |
705 VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
706 // At least one of the legal attachment bits must be set
707 if (0 == (pCreateInfo->usage & legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700708 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966",
709 "vkCreateImage(): Transient attachment image without a compatible attachment flag set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700710 }
711 // No flags other than the legal attachment bits may be set
712 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
713 if (0 != (pCreateInfo->usage & ~legal_flags)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700714 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963",
715 "vkCreateImage(): Transient attachment image with incompatible usage flags set.");
Dave Houlton130c0212018-01-29 13:39:56 -0700716 }
717 }
718
Jeff Bolzef40fec2018-09-01 22:04:34 -0500719 // mipLevels must be less than or equal to the number of levels in the complete mipmap chain
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600720 uint32_t maxDim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500721 // Max mip levels is different for corner-sampled images vs normal images.
Dave Houlton142c4cb2018-10-17 15:04:41 -0600722 uint32_t maxMipLevels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) ? (uint32_t)(ceil(log2(maxDim)))
723 : (uint32_t)(floor(log2(maxDim)) + 1);
Jeff Bolzef40fec2018-09-01 22:04:34 -0500724 if (maxDim > 0 && pCreateInfo->mipLevels > maxMipLevels) {
Dave Houlton413a6782018-05-22 13:01:54 -0600725 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700726 LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958",
727 "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to "
728 "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600729 }
730
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600731 if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700732 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950",
733 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but "
734 "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D.");
Mark Lobodzinski69259c52018-09-18 15:14:58 -0600735 }
736
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700737 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700738 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969",
739 "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the "
740 "VkPhysicalDeviceFeatures::sparseBinding feature is disabled.");
Petr Krausb6f97802018-03-13 12:31:39 +0100741 }
742
sfricke-samsung8f8cf052020-07-03 22:44:29 -0700743 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) {
744 skip |= LogError(
745 device, "VUID-VkImageCreateInfo-flags-01924",
746 "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the "
747 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set.");
748 }
749
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600750 // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain
751 // VK_IMAGE_CREATE_SPARSE_BINDING_BIT
752 if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) &&
753 ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700754 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987",
755 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or "
756 "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600757 }
758
759 // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set
760 if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) {
761 // Linear tiling is unsupported
762 if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) {
sfricke-samsung9801d752020-08-23 22:00:16 -0700763 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700764 "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image "
765 "tiling of VK_IMAGE_TILING_LINEAR is not supported");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600766 }
767
768 // Sparse 1D image isn't valid
769 if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700770 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970",
771 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600772 }
773
774 // Sparse 2D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700775 if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700776 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971",
777 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding "
778 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600779 }
780
781 // Sparse 3D image when device doesn't support it
Mark Lobodzinskibf599b92018-12-31 12:15:55 -0700782 if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700783 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972",
784 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding "
785 "feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600786 }
787
788 // Multi-sample 2D image when device doesn't support it
789 if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700790 if ((VK_FALSE == physical_device_features.sparseResidency2Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600791 (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700792 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973",
793 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if "
794 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700795 } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600796 (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700797 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974",
798 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if "
799 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700800 } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600801 (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700802 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975",
803 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if "
804 "corresponding feature is not enabled on the device.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -0700805 } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600806 (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700807 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976",
808 "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if "
809 "corresponding feature is not enabled on the device.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -0600810 }
811 }
812 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500813
Jeff Bolz9af91c52018-09-01 21:53:57 -0500814 if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) {
815 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700816 skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082",
817 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
818 "imageType must be VK_IMAGE_TYPE_2D.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500819 }
820 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700821 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083",
822 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
823 "samples must be VK_SAMPLE_COUNT_1_BIT.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500824 }
825 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700826 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084",
827 "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, "
828 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
Jeff Bolz9af91c52018-09-01 21:53:57 -0500829 }
830 }
Jeff Bolzef40fec2018-09-01 22:04:34 -0500831
832 if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) {
Dave Houlton142c4cb2018-10-17 15:04:41 -0600833 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700834 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050",
835 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
836 "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500837 }
838
Dave Houlton142c4cb2018-10-17 15:04:41 -0600839 if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700840 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051",
841 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, "
842 "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must "
843 "not be a depth/stencil format.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500844 }
845
Dave Houlton142c4cb2018-10-17 15:04:41 -0600846 if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700847 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052",
848 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
849 "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be "
850 "greater than 1.");
Jeff Bolzb8a8dd02018-09-18 02:39:24 -0500851 } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D &&
Dave Houlton142c4cb2018-10-17 15:04:41 -0600852 (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700853 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053",
854 "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and "
855 "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth "
856 "must be greater than 1.");
Jeff Bolzef40fec2018-09-01 22:04:34 -0500857 }
858 }
Andrew Fobel3abeb992020-01-20 16:33:22 -0500859
sfricke-samsung8f658d42020-05-03 20:12:24 -0700860 if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) &&
861 (FormatHasDepth(pCreateInfo->format) == false)) {
862 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533",
863 "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the "
864 "format must be a depth or depth/stencil format.");
865 }
866
Andrew Fobel3abeb992020-01-20 16:33:22 -0500867 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pCreateInfo->pNext);
868 if (image_stencil_struct != nullptr) {
869 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
870 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
871 // No flags other than the legal attachment bits may be set
872 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
873 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700874 skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
875 "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes "
876 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
877 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500878 }
879 }
880
881 if (FormatIsDepthOrStencil(pCreateInfo->format)) {
882 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) {
883 if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) {
884 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700885 LogError(device, "VUID-VkImageCreateInfo-Format-02536",
886 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
887 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device "
888 "maxFramebufferWidth");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500889 }
890
891 if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) {
892 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700893 LogError(device, "VUID-VkImageCreateInfo-format-02537",
894 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
895 "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device "
896 "maxFramebufferHeight");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500897 }
898 }
899
900 if (!physical_device_features.shaderStorageImageMultisample &&
901 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
902 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
903 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700904 LogError(device, "VUID-VkImageCreateInfo-format-02538",
905 "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with "
906 "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is "
907 "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
Andrew Fobel3abeb992020-01-20 16:33:22 -0500908 }
909
910 if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) &&
911 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700912 skip |= LogError(
913 device, "VUID-VkImageCreateInfo-format-02795",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500914 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
915 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
916 "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
917 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) &&
918 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700919 skip |= LogError(
920 device, "VUID-VkImageCreateInfo-format-02796",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500921 "vkCreateImage(): Depth-stencil image in which usage does not include "
922 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT "
923 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
924 "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT");
925 }
926
927 if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) &&
928 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700929 skip |= LogError(
930 device, "VUID-VkImageCreateInfo-format-02797",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500931 "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
932 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
933 "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
934 } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) &&
935 ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -0700936 skip |= LogError(
937 device, "VUID-VkImageCreateInfo-format-02798",
Andrew Fobel3abeb992020-01-20 16:33:22 -0500938 "vkCreateImage(): Depth-stencil image in which usage does not include "
939 "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT "
940 "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must "
941 "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT");
942 }
943 }
944 }
Spencer Frickeca52b5c2020-03-16 17:34:00 -0700945
946 if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) &&
947 (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) {
948 skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968",
949 "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images "
950 "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT");
951 }
Spencer Fricke6f8b8ac2020-04-06 07:36:50 -0700952
953 if (device_extensions.vk_ext_image_drm_format_modifier) {
954 const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext);
955 const auto drm_format_mod_explict =
956 lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext);
957 if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) {
958 if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) ||
959 ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) {
960 skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261",
961 "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have "
962 "either VkImageDrmFormatModifierListCreateInfoEXT or "
963 "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain");
964 }
965 } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) {
966 skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262",
967 "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a "
968 "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT "
969 "in the pNext chain");
970 }
971 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200972
973 if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) {
974 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
975 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557",
976 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
977 "imageType must be VK_IMAGE_TYPE_2D.");
978 }
979 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
980 skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558",
981 "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, "
982 "samples must be VK_SAMPLE_COUNT_1_BIT.");
983 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +0200984 }
985 if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) {
986 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
987 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565",
988 "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
989 "tiling must be VK_IMAGE_TILING_OPTIMAL.");
990 }
991 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
992 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566",
993 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
994 "imageType must be VK_IMAGE_TYPE_2D.");
995 }
996 if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) {
997 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567",
998 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, "
999 "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT.");
1000 }
1001 if (pCreateInfo->mipLevels != 1) {
1002 skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568",
1003 "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.",
1004 pCreateInfo->mipLevels);
1005 }
1006 }
sfricke-samsungddaf72b2020-06-23 21:39:28 -07001007
1008 const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext);
1009 if (swapchain_create_info != nullptr) {
1010 if (swapchain_create_info->swapchain != VK_NULL_HANDLE) {
1011 // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the
1012 // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information
1013 // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation
1014 const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995";
1015 const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image";
1016
1017 if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) {
1018 // also implicitly forces the check above that extent.depth is 1
1019 skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message,
1020 string_VkImageType(pCreateInfo->imageType));
1021 }
1022 if (pCreateInfo->mipLevels != 1) {
1023 skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message,
1024 pCreateInfo->mipLevels);
1025 }
1026 if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) {
1027 skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.",
1028 base_message, string_VkSampleCountFlagBits(pCreateInfo->samples));
1029 }
1030 if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) {
1031 skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.",
1032 base_message, string_VkImageTiling(pCreateInfo->tiling));
1033 }
1034 if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) {
1035 skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.",
1036 base_message, string_VkImageLayout(pCreateInfo->initialLayout));
1037 }
1038 const VkImageCreateFlags valid_flags =
1039 (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT |
1040 VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT_KHR);
1041 if ((pCreateInfo->flags & ~valid_flags) != 0) {
1042 skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message,
1043 pCreateInfo->flags);
1044 }
1045 }
1046 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001047 }
Jeff Bolzef40fec2018-09-01 22:04:34 -05001048
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001049 return skip;
1050}
1051
Jeff Bolz99e3f632020-03-24 22:59:22 -05001052bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo,
1053 const VkAllocationCallbacks *pAllocator, VkImageView *pView) const {
1054 bool skip = false;
1055
1056 if (pCreateInfo != nullptr) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001057 // Validate feature set if using CUBE_ARRAY
1058 if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) {
1059 skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004",
1060 "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without "
1061 "enabling the imageCubeArray feature.");
1062 }
1063
Jeff Bolz99e3f632020-03-24 22:59:22 -05001064 if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) {
1065 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) {
1066 skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960",
Spencer Fricke528e0982020-04-19 18:46:01 -07001067 "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.",
Jeff Bolz99e3f632020-03-24 22:59:22 -05001068 pCreateInfo->subresourceRange.layerCount);
1069 }
1070 if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) {
Spencer Fricke528e0982020-04-19 18:46:01 -07001071 skip |= LogError(
1072 device, "VUID-VkImageViewCreateInfo-viewType-02961",
1073 "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.",
1074 pCreateInfo->subresourceRange.layerCount);
Jeff Bolz99e3f632020-03-24 22:59:22 -05001075 }
1076 }
sfricke-samsung0c4a06f2020-06-27 01:24:32 -07001077
1078 auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext);
1079 if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) {
1080 if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) &&
1081 (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) &&
1082 (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) {
1083 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230",
1084 "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be "
1085 "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32.");
1086 }
1087 if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) {
1088 skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084",
1089 "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and "
1090 "not an ASTC format.",
1091 string_VkFormat(pCreateInfo->format));
1092 }
1093 }
sfricke-samsung83d98122020-07-04 06:21:15 -07001094
1095 auto ycbcr_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
1096 if (ycbcr_conversion != nullptr) {
1097 if (ycbcr_conversion->conversion != VK_NULL_HANDLE) {
1098 if (IsIdentitySwizzle(pCreateInfo->components) == false) {
1099 skip |= LogError(
1100 device, "VUID-VkImageViewCreateInfo-pNext-01970",
1101 "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must "
1102 "be created with the identity swizzle. Here are the actual swizzle values:\n"
1103 "r swizzle = %s\n"
1104 "g swizzle = %s\n"
1105 "b swizzle = %s\n"
1106 "a swizzle = %s\n",
1107 string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g),
1108 string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a));
1109 }
1110 }
1111 }
Jeff Bolz99e3f632020-03-24 22:59:22 -05001112 }
1113 return skip;
1114}
1115
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001116bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001117 const ParameterName &parameter_name, VkCommandBuffer object) const {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001118 bool skip = false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001119
1120 // Note: for numerical correctness
1121 // - float comparisons should expect NaN (comparison always false).
1122 // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful.
1123
1124 const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) {
John Zulaufac0876c2018-02-19 10:09:35 -07001125 if (std::isnan(v1_f)) return false;
Petr Krausb3fcdb42018-01-09 22:09:09 +01001126 if (v1_f <= 0.0f) return true;
1127
1128 float intpart;
1129 const float fract = modff(v1_f, &intpart);
1130
1131 assert(std::numeric_limits<float>::radix == 2);
1132 const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact
1133 if (intpart >= u32_max_plus1) return false;
1134
1135 uint32_t v1_u32 = static_cast<uint32_t>(intpart);
1136 if (v1_u32 < v2_u32)
1137 return true;
1138 else if (v1_u32 == v2_u32 && fract == 0.0f)
1139 return true;
1140 else
1141 return false;
1142 };
1143
1144 const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) {
1145 const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode
1146 return (v1_f <= v2_f);
1147 };
1148
1149 // width
1150 bool width_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001151 const auto max_w = device_limits.maxViewportDimensions[0];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001152
1153 if (!(viewport.width > 0.0f)) {
1154 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001155 skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name,
1156 parameter_name.get_name().c_str(), viewport.width);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001157 } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) {
1158 width_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001159 skip |= LogError(object, "VUID-VkViewport-width-01771",
1160 "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name,
1161 parameter_name.get_name().c_str(), viewport.width, max_w);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001162 }
1163
1164 // height
1165 bool height_healthy = true;
Mark Lobodzinskia09ab942020-02-20 11:01:59 -07001166 const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001167 const auto max_h = device_limits.maxViewportDimensions[1];
Petr Krausb3fcdb42018-01-09 22:09:09 +01001168
1169 if (!negative_height_enabled && !(viewport.height > 0.0f)) {
1170 height_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001171 skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name,
1172 parameter_name.get_name().c_str(), viewport.height);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001173 } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) {
1174 height_healthy = false;
1175
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001176 skip |= LogError(object, "VUID-VkViewport-height-01773",
1177 "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32
1178 ").",
1179 fn_name, parameter_name.get_name().c_str(), viewport.height, max_h);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001180 }
1181
1182 // x
1183 bool x_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001184 if (!(viewport.x >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001185 x_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001186 skip |= LogError(object, "VUID-VkViewport-x-01774",
1187 "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1188 parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001189 }
1190
1191 // x + width
1192 if (x_healthy && width_healthy) {
1193 const float right_bound = viewport.x + viewport.width;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001194 if (!(right_bound <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001195 skip |= LogError(
1196 object, "VUID-VkViewport-x-01232",
1197 "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1198 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width,
1199 right_bound, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001200 }
1201 }
1202
1203 // y
1204 bool y_healthy = true;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001205 if (!(viewport.y >= device_limits.viewportBoundsRange[0])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001206 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001207 skip |= LogError(object, "VUID-VkViewport-y-01775",
1208 "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name,
1209 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001210 } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001211 y_healthy = false;
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001212 skip |= LogError(object, "VUID-VkViewport-y-01776",
1213 "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name,
1214 parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001215 }
1216
1217 // y + height
1218 if (y_healthy && height_healthy) {
1219 const float boundary = viewport.y + viewport.height;
1220
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001221 if (!(boundary <= device_limits.viewportBoundsRange[1])) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001222 skip |= LogError(object, "VUID-VkViewport-y-01233",
1223 "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).",
1224 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y,
1225 viewport.height, boundary, device_limits.viewportBoundsRange[1]);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001226 } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) {
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06001227 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001228 LogError(object, "VUID-VkViewport-y-01777",
1229 "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).",
1230 fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height,
1231 boundary, device_limits.viewportBoundsRange[0]);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001232 }
1233 }
1234
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001235 if (!device_extensions.vk_ext_depth_range_unrestricted) {
Petr Krausb3fcdb42018-01-09 22:09:09 +01001236 // minDepth
1237 if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001238 skip |= LogError(object, "VUID-VkViewport-minDepth-01234",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001239
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001240 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the "
1241 "[0.0, 1.0] range.",
1242 fn_name, parameter_name.get_name().c_str(), viewport.minDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001243 }
1244
1245 // maxDepth
1246 if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001247 skip |= LogError(object, "VUID-VkViewport-maxDepth-01235",
Mark Lobodzinski88529492018-04-01 10:38:15 -06001248
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001249 "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the "
1250 "[0.0, 1.0] range.",
1251 fn_name, parameter_name.get_name().c_str(), viewport.maxDepth);
Petr Krausb3fcdb42018-01-09 22:09:09 +01001252 }
1253 }
1254
1255 return skip;
1256}
1257
Dave Houlton142c4cb2018-10-17 15:04:41 -06001258struct SampleOrderInfo {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001259 VkShadingRatePaletteEntryNV shadingRate;
1260 uint32_t width;
1261 uint32_t height;
1262};
1263
1264// All palette entries with more than one pixel per fragment
Dave Houlton142c4cb2018-10-17 15:04:41 -06001265static SampleOrderInfo sampleOrderInfos[] = {
1266 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2},
1267 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1},
1268 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2},
1269 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2},
1270 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4},
1271 {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4},
Jeff Bolz9af91c52018-09-01 21:53:57 -05001272};
1273
Jeff Bolz46c0ea02019-10-09 13:06:29 -05001274bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001275 bool skip = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001276
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001277 SampleOrderInfo *sampleOrderInfo;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001278 uint32_t infoIdx = 0;
Jeff Bolz45bf7d62018-09-18 15:39:58 -05001279 for (sampleOrderInfo = nullptr; infoIdx < ARRAY_SIZE(sampleOrderInfos); ++infoIdx) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05001280 if (sampleOrderInfos[infoIdx].shadingRate == order->shadingRate) {
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001281 sampleOrderInfo = &sampleOrderInfos[infoIdx];
Jeff Bolz9af91c52018-09-01 21:53:57 -05001282 break;
1283 }
1284 }
1285
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001286 if (sampleOrderInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001287 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073",
1288 "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate "
1289 "that generates fragments with more than one pixel.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001290 return skip;
1291 }
1292
Dave Houlton142c4cb2018-10-17 15:04:41 -06001293 if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) ||
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001294 !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001295 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074",
1296 "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32
1297 ") must "
1298 "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit "
1299 "is set in framebufferNoAttachmentsSampleCounts.",
1300 order->sampleCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001301 }
1302
Jeff Bolz9af91c52018-09-01 21:53:57 -05001303 if (order->sampleLocationCount != order->sampleCount * sampleOrderInfo->width * sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001304 skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075",
1305 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1306 ") must "
1307 "be equal to the product of sampleCount (=%" PRIu32
1308 "), the fragment width for shadingRate "
1309 "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").",
1310 order->sampleLocationCount, order->sampleCount, sampleOrderInfo->width, sampleOrderInfo->height);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001311 }
1312
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001313 if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001314 skip |= LogError(
1315 device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001316 "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32
1317 ") must "
1318 "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001319 order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001320 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05001321
1322 // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001323 // the first width*height*sampleCount bits to all be set. Note: There is no
1324 // guarantee that 64 bits is enough, but practically it's unlikely for an
1325 // implementation to support more than 32 bits for samplemask.
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001326 assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64);
Jeff Bolz9af91c52018-09-01 21:53:57 -05001327 uint64_t sampleLocationsMask = 0;
1328 for (uint32_t i = 0; i < order->sampleLocationCount; ++i) {
1329 const VkCoarseSampleLocationNV *sampleLoc = &order->pSampleLocations[i];
1330 if (sampleLoc->pixelX >= sampleOrderInfo->width) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001331 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078",
1332 "pixelX must be less than the width (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001333 }
1334 if (sampleLoc->pixelY >= sampleOrderInfo->height) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001335 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079",
1336 "pixelY must be less than the height (in pixels) of the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001337 }
1338 if (sampleLoc->sample >= order->sampleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001339 skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080",
1340 "sample must be less than the number of coverage samples in each pixel belonging to the fragment.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001341 }
1342 uint32_t idx = sampleLoc->sample + order->sampleCount * (sampleLoc->pixelX + sampleOrderInfo->width * sampleLoc->pixelY);
1343 sampleLocationsMask |= 1ULL << idx;
1344 }
1345
1346 uint64_t expectedMask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1);
1347 if (sampleLocationsMask != expectedMask) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001348 skip |= LogError(
1349 device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077",
Dave Houlton142c4cb2018-10-17 15:04:41 -06001350 "The array pSampleLocations must contain exactly one entry for "
1351 "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05001352 }
1353
1354 return skip;
1355}
1356
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07001357bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache,
1358 uint32_t createInfoCount,
1359 const VkGraphicsPipelineCreateInfo *pCreateInfos,
1360 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05001361 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001362 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001363
1364 if (pCreateInfos != nullptr) {
1365 for (uint32_t i = 0; i < createInfoCount; ++i) {
Petr Kraus299ba622017-11-24 03:09:03 +01001366 bool has_dynamic_viewport = false;
1367 bool has_dynamic_scissor = false;
1368 bool has_dynamic_line_width = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001369 bool has_dynamic_depth_bias = false;
1370 bool has_dynamic_blend_constant = false;
1371 bool has_dynamic_depth_bounds = false;
1372 bool has_dynamic_stencil_compare = false;
1373 bool has_dynamic_stencil_write = false;
1374 bool has_dynamic_stencil_reference = false;
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07001375 bool has_dynamic_viewport_w_scaling_nv = false;
1376 bool has_dynamic_discard_rectangle_ext = false;
1377 bool has_dynamic_sample_locations_ext = false;
Jeff Bolz3e71f782018-08-29 23:15:45 -05001378 bool has_dynamic_exclusive_scissor_nv = false;
Jeff Bolz9af91c52018-09-01 21:53:57 -05001379 bool has_dynamic_shading_rate_palette_nv = false;
Spencer Fricke8d428882020-03-16 17:23:33 -07001380 bool has_dynamic_viewport_course_sample_order_nv = false;
Jeff Bolz8125a8b2019-08-16 16:29:45 -05001381 bool has_dynamic_line_stipple = false;
Piers Daniell39842ee2020-07-10 16:42:33 -06001382 bool has_dynamic_cull_mode = false;
1383 bool has_dynamic_front_face = false;
1384 bool has_dynamic_primitive_topology = false;
1385 bool has_dynamic_viewport_with_count = false;
1386 bool has_dynamic_scissor_with_count = false;
1387 bool has_dynamic_vertex_input_binding_stride = false;
1388 bool has_dynamic_depth_test_enable = false;
1389 bool has_dynamic_depth_write_enable = false;
1390 bool has_dynamic_depth_compare_op = false;
1391 bool has_dynamic_depth_bounds_test_enable = false;
1392 bool has_dynamic_stencil_test_enable = false;
1393 bool has_dynamic_stencil_op = false;
Petr Kraus299ba622017-11-24 03:09:03 +01001394 if (pCreateInfos[i].pDynamicState != nullptr) {
1395 const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState;
1396 for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) {
1397 const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index];
Spencer Fricke8d428882020-03-16 17:23:33 -07001398 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) {
1399 if (has_dynamic_viewport == true) {
1400 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1401 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the "
1402 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1403 i);
1404 }
1405 has_dynamic_viewport = true;
1406 }
1407 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) {
1408 if (has_dynamic_scissor == true) {
1409 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1410 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the "
1411 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1412 i);
1413 }
1414 has_dynamic_scissor = true;
1415 }
1416 if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) {
1417 if (has_dynamic_line_width == true) {
1418 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1419 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the "
1420 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1421 i);
1422 }
1423 has_dynamic_line_width = true;
1424 }
1425 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) {
1426 if (has_dynamic_depth_bias == true) {
1427 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1428 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the "
1429 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1430 i);
1431 }
1432 has_dynamic_depth_bias = true;
1433 }
1434 if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) {
1435 if (has_dynamic_blend_constant == true) {
1436 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1437 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the "
1438 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1439 i);
1440 }
1441 has_dynamic_blend_constant = true;
1442 }
1443 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) {
1444 if (has_dynamic_depth_bounds == true) {
1445 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1446 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the "
1447 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1448 i);
1449 }
1450 has_dynamic_depth_bounds = true;
1451 }
1452 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) {
1453 if (has_dynamic_stencil_compare == true) {
1454 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1455 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in "
1456 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1457 i);
1458 }
1459 has_dynamic_stencil_compare = true;
1460 }
1461 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) {
1462 if (has_dynamic_stencil_write == true) {
1463 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1464 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in "
1465 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1466 i);
1467 }
1468 has_dynamic_stencil_write = true;
1469 }
1470 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) {
1471 if (has_dynamic_stencil_reference == true) {
1472 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1473 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in "
1474 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1475 i);
1476 }
1477 has_dynamic_stencil_reference = true;
1478 }
1479 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) {
1480 if (has_dynamic_viewport_w_scaling_nv == true) {
1481 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1482 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice "
1483 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1484 i);
1485 }
1486 has_dynamic_viewport_w_scaling_nv = true;
1487 }
1488 if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) {
1489 if (has_dynamic_discard_rectangle_ext == true) {
1490 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1491 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice "
1492 "in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1493 i);
1494 }
1495 has_dynamic_discard_rectangle_ext = true;
1496 }
1497 if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) {
1498 if (has_dynamic_sample_locations_ext == true) {
1499 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1500 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in "
1501 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1502 i);
1503 }
1504 has_dynamic_sample_locations_ext = true;
1505 }
1506 if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) {
1507 if (has_dynamic_exclusive_scissor_nv == true) {
1508 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1509 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in "
1510 "the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1511 i);
1512 }
1513 has_dynamic_exclusive_scissor_nv = true;
1514 }
1515 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) {
1516 if (has_dynamic_shading_rate_palette_nv == true) {
1517 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1518 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was "
1519 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1520 i);
1521 }
Dave Houlton142c4cb2018-10-17 15:04:41 -06001522 has_dynamic_shading_rate_palette_nv = true;
Spencer Fricke8d428882020-03-16 17:23:33 -07001523 }
1524 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) {
1525 if (has_dynamic_viewport_course_sample_order_nv == true) {
1526 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1527 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was "
1528 "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array",
1529 i);
1530 }
1531 has_dynamic_viewport_course_sample_order_nv = true;
1532 }
1533 if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) {
1534 if (has_dynamic_line_stipple == true) {
1535 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1536 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the "
1537 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1538 i);
1539 }
1540 has_dynamic_line_stipple = true;
1541 }
Piers Daniell39842ee2020-07-10 16:42:33 -06001542 if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) {
1543 if (has_dynamic_cull_mode) {
1544 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1545 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the "
1546 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1547 i);
1548 }
1549 has_dynamic_cull_mode = true;
1550 }
1551 if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) {
1552 if (has_dynamic_front_face) {
1553 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1554 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the "
1555 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1556 i);
1557 }
1558 has_dynamic_front_face = true;
1559 }
1560 if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) {
1561 if (has_dynamic_primitive_topology) {
1562 skip |= LogError(
1563 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1564 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the "
1565 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1566 i);
1567 }
1568 has_dynamic_primitive_topology = true;
1569 }
1570 if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) {
1571 if (has_dynamic_viewport_with_count) {
1572 skip |= LogError(
1573 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1574 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the "
1575 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1576 i);
1577 }
1578 has_dynamic_viewport_with_count = true;
1579 }
1580 if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) {
1581 if (has_dynamic_scissor_with_count) {
1582 skip |= LogError(
1583 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1584 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the "
1585 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1586 i);
1587 }
1588 has_dynamic_scissor_with_count = true;
1589 }
1590 if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) {
1591 if (has_dynamic_vertex_input_binding_stride) {
1592 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1593 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was "
1594 "listed twice in the "
1595 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1596 i);
1597 }
1598 has_dynamic_vertex_input_binding_stride = true;
1599 }
1600 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) {
1601 if (has_dynamic_depth_test_enable) {
1602 skip |= LogError(
1603 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1604 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the "
1605 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1606 i);
1607 }
1608 has_dynamic_depth_test_enable = true;
1609 }
1610 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) {
1611 if (has_dynamic_depth_write_enable) {
1612 skip |= LogError(
1613 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1614 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the "
1615 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1616 i);
1617 }
1618 has_dynamic_depth_write_enable = true;
1619 }
1620 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) {
1621 if (has_dynamic_depth_compare_op) {
1622 skip |=
1623 LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1624 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the "
1625 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1626 i);
1627 }
1628 has_dynamic_depth_compare_op = true;
1629 }
1630 if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) {
1631 if (has_dynamic_depth_bounds_test_enable) {
1632 skip |= LogError(
1633 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1634 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the "
1635 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1636 i);
1637 }
1638 has_dynamic_depth_bounds_test_enable = true;
1639 }
1640 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) {
1641 if (has_dynamic_stencil_test_enable) {
1642 skip |= LogError(
1643 device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1644 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the "
1645 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1646 i);
1647 }
1648 has_dynamic_stencil_test_enable = true;
1649 }
1650 if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) {
1651 if (has_dynamic_stencil_op) {
1652 skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442",
1653 "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the "
1654 "pCreateInfos[%d].pDynamicState->pDynamicStates array",
1655 i);
1656 }
1657 has_dynamic_stencil_op = true;
1658 }
Petr Kraus299ba622017-11-24 03:09:03 +01001659 }
1660 }
1661
Peter Chen85366392019-05-14 15:20:11 -04001662 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
1663 if ((feedback_struct != nullptr) &&
1664 (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001665 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668",
1666 "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32
1667 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
1668 "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").",
1669 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04001670 }
1671
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001672 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001673
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001674 // Collect active stages and other information
1675 // Only want to loop through pStages once
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001676 uint32_t active_shaders = 0;
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001677 bool has_eval = false;
1678 bool has_control = false;
1679 if (pCreateInfos[i].pStages != nullptr) {
1680 for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) {
1681 active_shaders |= pCreateInfos[i].pStages[stage_index].stage;
1682
1683 if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) {
1684 has_control = true;
1685 } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) {
1686 has_eval = true;
1687 }
1688
1689 skip |= validate_string(
1690 "vkCreateGraphicsPipelines",
1691 ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}),
1692 "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName);
1693 }
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001694 }
1695
1696 if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) &&
1697 (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) {
1698 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState",
1699 "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO",
1700 pCreateInfos[i].pTessellationState,
1701 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined,
1702 "VUID-VkPipelineTessellationStateCreateInfo-sType-sType");
1703
1704 const VkStructureType allowed_structs_VkPipelineTessellationStateCreateInfo[] = {
1705 VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO};
1706
1707 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext",
1708 "VkPipelineTessellationDomainOriginStateCreateInfo",
1709 pCreateInfos[i].pTessellationState->pNext,
1710 ARRAY_SIZE(allowed_structs_VkPipelineTessellationStateCreateInfo),
1711 allowed_structs_VkPipelineTessellationStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001712 "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext",
1713 "VUID-VkPipelineTessellationStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001714
1715 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags",
1716 pCreateInfos[i].pTessellationState->flags,
1717 "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
1718 }
1719
1720 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) {
1721 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState",
1722 "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO",
1723 pCreateInfos[i].pInputAssemblyState,
1724 VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined,
1725 "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType");
1726
1727 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL,
1728 pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001729 "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001730
1731 skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags",
1732 pCreateInfos[i].pInputAssemblyState->flags,
1733 "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask");
1734
1735 skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology",
1736 "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums,
1737 pCreateInfos[i].pInputAssemblyState->topology,
1738 "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter");
1739
1740 skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable",
1741 pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable);
1742 }
1743
1744 if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001745 auto const &vertex_input_state = pCreateInfos[i].pVertexInputState;
Peter Kohautc7d9d392018-07-15 00:34:07 +02001746
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001747 if (pCreateInfos[i].pVertexInputState->flags != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001748 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask",
1749 "vkCreateGraphicsPipelines: pararameter "
1750 "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.",
1751 i, vertex_input_state->flags);
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001752 }
1753
1754 const VkStructureType allowed_structs_VkPipelineVertexInputStateCreateInfo[] = {
1755 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT};
1756 skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext",
1757 "VkPipelineVertexInputDivisorStateCreateInfoEXT",
1758 pCreateInfos[i].pVertexInputState->pNext, 1,
1759 allowed_structs_VkPipelineVertexInputStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08001760 "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext",
1761 "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001762 skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState",
1763 "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state,
Shannon McPherson3cc90bc2019-08-13 11:28:22 -06001764 VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined,
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06001765 "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType");
1766 skip |=
1767 validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount",
1768 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions",
1769 pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount,
1770 &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined,
1771 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter");
1772
1773 skip |= validate_array(
1774 "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount",
1775 "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount,
1776 &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined,
1777 "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter");
1778
1779 if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) {
1780 for (uint32_t vertexBindingDescriptionIndex = 0;
1781 vertexBindingDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount;
1782 ++vertexBindingDescriptionIndex) {
1783 skip |= validate_ranged_enum(
1784 "vkCreateGraphicsPipelines",
1785 "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate",
1786 AllVkVertexInputRateEnums,
1787 pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[vertexBindingDescriptionIndex].inputRate,
1788 "VUID-VkVertexInputBindingDescription-inputRate-parameter");
1789 }
1790 }
1791
1792 if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) {
1793 for (uint32_t vertexAttributeDescriptionIndex = 0;
1794 vertexAttributeDescriptionIndex < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount;
1795 ++vertexAttributeDescriptionIndex) {
1796 skip |= validate_ranged_enum(
1797 "vkCreateGraphicsPipelines",
1798 "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat",
1799 AllVkFormatEnums,
1800 pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[vertexAttributeDescriptionIndex].format,
1801 "VUID-VkVertexInputAttributeDescription-format-parameter");
1802 }
1803 }
1804
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001805 if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001806 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613",
1807 "vkCreateGraphicsPipelines: pararameter "
1808 "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is "
1809 "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1810 i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001811 }
1812
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001813 if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001814 skip |=
1815 LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614",
1816 "vkCreateGraphicsPipelines: pararameter "
1817 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is "
1818 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1819 i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001820 }
1821
1822 std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001823 for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) {
1824 auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001825 auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding);
1826 if (binding_it != vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001827 skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616",
1828 "vkCreateGraphicsPipelines: parameter "
1829 "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding "
1830 "(%" PRIu32 ") is not distinct.",
1831 i, d, vertex_bind_desc.binding);
Peter Kohautc7d9d392018-07-15 00:34:07 +02001832 }
1833 vertex_bindings.insert(vertex_bind_desc.binding);
1834
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001835 if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001836 skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618",
1837 "vkCreateGraphicsPipelines: parameter "
1838 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is "
1839 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1840 i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001841 }
1842
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001843 if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001844 skip |=
1845 LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619",
1846 "vkCreateGraphicsPipelines: parameter "
1847 "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater "
1848 "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).",
1849 i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001850 }
1851 }
1852
Peter Kohautc7d9d392018-07-15 00:34:07 +02001853 std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001854 for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) {
1855 auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d];
Peter Kohautc7d9d392018-07-15 00:34:07 +02001856 auto const &location_it = attribute_locations.find(vertex_attrib_desc.location);
1857 if (location_it != attribute_locations.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001858 skip |= LogError(
1859 device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001860 "vkCreateGraphicsPipelines: parameter "
1861 "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.",
1862 i, d, vertex_attrib_desc.location);
1863 }
1864 attribute_locations.insert(vertex_attrib_desc.location);
1865
1866 auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding);
1867 if (binding_it == vertex_bindings.cend()) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001868 skip |= LogError(
1869 device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615",
Peter Kohautc7d9d392018-07-15 00:34:07 +02001870 "vkCreateGraphicsPipelines: parameter "
1871 " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist "
1872 "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.",
1873 i, d, vertex_attrib_desc.binding, i);
1874 }
1875
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001876 if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001877 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620",
1878 "vkCreateGraphicsPipelines: parameter "
1879 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is "
1880 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).",
1881 i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001882 }
1883
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001884 if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001885 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621",
1886 "vkCreateGraphicsPipelines: parameter "
1887 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is "
1888 "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).",
1889 i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001890 }
1891
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001892 if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001893 skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622",
1894 "vkCreateGraphicsPipelines: parameter "
1895 "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is "
1896 "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).",
1897 i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001898 }
1899 }
1900 }
1901
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001902 // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages
1903 if (has_control && has_eval) {
1904 if (pCreateInfos[i].pTessellationState == nullptr) {
1905 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731",
1906 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control "
1907 "shader stage and a tessellation evaluation shader stage, "
1908 "pCreateInfos[%d].pTessellationState must not be NULL.",
1909 i, i);
1910 } else {
1911 const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO;
1912 skip |= validate_struct_pnext(
1913 "vkCreateGraphicsPipelines",
1914 ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}),
1915 "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1,
1916 &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext",
1917 "VUID-VkGraphicsPipelineCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001918
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001919 skip |= validate_reserved_flags(
1920 "vkCreateGraphicsPipelines",
1921 ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}),
1922 pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001923
Spencer Frickef1b0a7d2020-03-16 17:38:55 -07001924 if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 ||
1925 pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) {
1926 skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214",
1927 "vkCreateGraphicsPipelines: invalid parameter "
1928 "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints "
1929 "should be >0 and <=%u.",
1930 i, pCreateInfos[i].pTessellationState->patchControlPoints,
1931 device_limits.maxTessellationPatchSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001932 }
1933 }
1934 }
1935
1936 // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled
1937 if ((pCreateInfos[i].pRasterizationState != nullptr) &&
1938 (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) {
1939 if (pCreateInfos[i].pViewportState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001940 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750",
1941 "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32
1942 "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32
1943 "].pViewportState (=NULL) is not a valid pointer.",
1944 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001945 } else {
Petr Krausa6103552017-11-16 21:21:58 +01001946 const auto &viewport_state = *pCreateInfos[i].pViewportState;
1947
1948 if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001949 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType",
1950 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
1951 "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.",
1952 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001953 }
1954
Petr Krausa6103552017-11-16 21:21:58 +01001955 const VkStructureType allowed_structs_VkPipelineViewportStateCreateInfo[] = {
1956 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001957 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV,
1958 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV,
Jeff Bolz9af91c52018-09-01 21:53:57 -05001959 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV,
1960 VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV,
Jeff Bolz3e71f782018-08-29 23:15:45 -05001961 };
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001962 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001963 "vkCreateGraphicsPipelines",
Petr Krausa6103552017-11-16 21:21:58 +01001964 ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}),
Jeff Bolz9af91c52018-09-01 21:53:57 -05001965 "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, "
Jeff Bolzb8a8dd02018-09-18 02:39:24 -05001966 "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, "
1967 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV",
Petr Krausa6103552017-11-16 21:21:58 +01001968 viewport_state.pNext, ARRAY_SIZE(allowed_structs_VkPipelineViewportStateCreateInfo),
sfricke-samsung32a27362020-02-28 09:06:42 -08001969 allowed_structs_VkPipelineViewportStateCreateInfo, 65, "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext",
1970 "VUID-VkPipelineViewportStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001971
1972 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001973 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001974 ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06001975 viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001976
Dave Houlton142c4cb2018-10-17 15:04:41 -06001977 auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>(
1978 pCreateInfos[i].pViewportState->pNext);
1979 auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>(
1980 pCreateInfos[i].pViewportState->pNext);
1981 auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>(
1982 pCreateInfos[i].pViewportState->pNext);
Chris Mayer328d8212018-12-11 14:16:18 +01001983 const auto vp_swizzle_struct =
1984 lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02001985 const auto vp_w_scaling_struct =
1986 lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext);
Jeff Bolz3e71f782018-08-29 23:15:45 -05001987
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07001988 if (!physical_device_features.multiViewport) {
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06001989 if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001990 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216",
1991 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
1992 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32
1993 ") is not 1.",
1994 i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01001995 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06001996
Mark Lobodzinski8b9ddab2020-10-15 14:38:43 -06001997 if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07001998 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217",
1999 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2000 "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32
2001 ") is not 1.",
2002 i, viewport_state.scissorCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002003 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002004
Dave Houlton142c4cb2018-10-17 15:04:41 -06002005 if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 &&
2006 exclusive_scissor_struct->exclusiveScissorCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002007 skip |= LogError(
2008 device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027",
2009 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2010 "disabled, but pCreateInfos[%" PRIu32
2011 "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32
2012 ") is not 1.",
2013 i, exclusive_scissor_struct->exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002014 }
2015
Jeff Bolz9af91c52018-09-01 21:53:57 -05002016 if (shading_rate_image_struct &&
2017 (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002018 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054",
2019 "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is "
2020 "disabled, but pCreateInfos[%" PRIu32
2021 "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32
2022 ") is neither 0 nor 1.",
2023 i, shading_rate_image_struct->viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002024 }
2025
Petr Krausa6103552017-11-16 21:21:58 +01002026 } else { // multiViewport enabled
2027 if (viewport_state.viewportCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002028 if (!has_dynamic_viewport_with_count) {
2029 skip |= LogError(
2030 device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength",
2031 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i);
2032 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002033 } else if (viewport_state.viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002034 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218",
2035 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2036 "].pViewportState->viewportCount (=%" PRIu32
2037 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2038 i, viewport_state.viewportCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002039 } else if (has_dynamic_viewport_with_count) {
2040 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379",
2041 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2042 "].pViewportState->viewportCount (=%" PRIu32
2043 ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.",
2044 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002045 }
Petr Krausa6103552017-11-16 21:21:58 +01002046
2047 if (viewport_state.scissorCount == 0) {
Piers Daniell39842ee2020-07-10 16:42:33 -06002048 if (!has_dynamic_scissor_with_count) {
2049 skip |= LogError(
2050 device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength",
2051 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i);
2052 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002053 } else if (viewport_state.scissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002054 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219",
2055 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2056 "].pViewportState->scissorCount (=%" PRIu32
2057 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2058 i, viewport_state.scissorCount, device_limits.maxViewports);
Piers Daniell39842ee2020-07-10 16:42:33 -06002059 } else if (has_dynamic_scissor_with_count) {
2060 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380",
2061 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2062 "].pViewportState->scissorCount (=%" PRIu32
2063 ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.",
2064 i, viewport_state.viewportCount);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002065 }
2066 }
2067
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002068 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002069 skip |=
2070 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028",
2071 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2072 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2073 i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002074 }
2075
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002076 if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002077 skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055",
2078 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2079 "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2080 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
2081 i, shading_rate_image_struct->viewportCount, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002082 }
2083
Piers Daniell39842ee2020-07-10 16:42:33 -06002084 if (viewport_state.scissorCount != viewport_state.viewportCount &&
2085 !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002086 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220",
2087 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2088 "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32
2089 "].pViewportState->viewportCount (=%" PRIu32 ").",
2090 i, viewport_state.scissorCount, i, viewport_state.viewportCount);
Petr Krausa6103552017-11-16 21:21:58 +01002091 }
2092
Dave Houlton142c4cb2018-10-17 15:04:41 -06002093 if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 &&
Jeff Bolz3e71f782018-08-29 23:15:45 -05002094 exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002095 skip |=
2096 LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029",
2097 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32
2098 ") must be zero or identical to pCreateInfos[%" PRIu32
2099 "].pViewportState->viewportCount (=%" PRIu32 ").",
2100 i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002101 }
2102
Dave Houlton142c4cb2018-10-17 15:04:41 -06002103 if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable &&
Jeff Bolz9af91c52018-09-01 21:53:57 -05002104 shading_rate_image_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002105 skip |= LogError(
2106 device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056",
Dave Houlton142c4cb2018-10-17 15:04:41 -06002107 "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32
2108 "] "
2109 "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32
2110 ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").",
2111 i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002112 }
2113
Petr Krausa6103552017-11-16 21:21:58 +01002114 if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002115 skip |= LogError(
2116 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747",
Petr Krausa6103552017-11-16 21:21:58 +01002117 "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32
2118 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002119 "].pViewportState->pViewports (=NULL) is an invalid pointer.",
2120 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002121 }
2122
2123 if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002124 skip |= LogError(
2125 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748",
Petr Krausa6103552017-11-16 21:21:58 +01002126 "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32
2127 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06002128 "].pViewportState->pScissors (=NULL) is an invalid pointer.",
2129 i, i);
Petr Krausa6103552017-11-16 21:21:58 +01002130 }
2131
Jeff Bolz3e71f782018-08-29 23:15:45 -05002132 if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002133 exclusive_scissor_struct->exclusiveScissorCount > 0 &&
2134 exclusive_scissor_struct->pExclusiveScissors == nullptr) {
2135 skip |=
Shannon McPherson24c13d12020-06-18 15:51:41 -06002136 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002137 "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32
2138 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but "
2139 "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.",
2140 i, i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002141 }
2142
Jeff Bolz9af91c52018-09-01 21:53:57 -05002143 if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct &&
Dave Houlton142c4cb2018-10-17 15:04:41 -06002144 shading_rate_image_struct->viewportCount > 0 &&
2145 shading_rate_image_struct->pShadingRatePalettes == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002146 skip |= LogError(
Shannon McPherson24c13d12020-06-18 15:51:41 -06002147 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002148 "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32
Dave Houlton142c4cb2018-10-17 15:04:41 -06002149 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), "
2150 "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.",
Jeff Bolz9af91c52018-09-01 21:53:57 -05002151 i, i);
2152 }
2153
Chris Mayer328d8212018-12-11 14:16:18 +01002154 if (vp_swizzle_struct) {
2155 if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002156 skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215",
2157 "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32
2158 " does "
2159 "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.",
2160 vp_swizzle_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer328d8212018-12-11 14:16:18 +01002161 }
2162 }
2163
Petr Krausb3fcdb42018-01-09 22:09:09 +01002164 // validate the VkViewports
2165 if (!has_dynamic_viewport && viewport_state.pViewports) {
2166 for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) {
2167 const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06002168 const char *fn_name = "vkCreateGraphicsPipelines";
2169 skip |= manual_PreCallValidateViewport(viewport, fn_name,
2170 ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]",
2171 ParameterName::IndexVector{i, viewport_i}),
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002172 VkCommandBuffer(0));
Petr Krausb3fcdb42018-01-09 22:09:09 +01002173 }
2174 }
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002175
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002176 if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002177 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2178 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2179 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but "
2180 "VK_NV_clip_space_w_scaling extension is not enabled.",
2181 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002182 }
2183
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002184 if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002185 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2186 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2187 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but "
2188 "VK_EXT_discard_rectangles extension is not enabled.",
2189 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002190 }
2191
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002192 if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002193 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2194 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2195 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but "
2196 "VK_EXT_sample_locations extension is not enabled.",
2197 i);
Jeremy Kniager71fd5f02017-11-15 13:27:03 -07002198 }
Jeff Bolz3e71f782018-08-29 23:15:45 -05002199
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002200 if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002201 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2202 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2203 "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but "
2204 "VK_NV_scissor_exclusive extension is not enabled.",
2205 i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05002206 }
Jeff Bolz9af91c52018-09-01 21:53:57 -05002207
2208 if (coarse_sample_order_struct &&
2209 coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV &&
2210 coarse_sample_order_struct->customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002211 skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072",
2212 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2213 "] "
2214 "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not "
2215 "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.",
2216 i);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002217 }
2218
2219 if (coarse_sample_order_struct) {
2220 for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002221 skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05002222 }
2223 }
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002224
2225 if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) {
2226 if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002227 skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726",
2228 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2229 "] "
2230 "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32
2231 ") "
2232 "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").",
2233 i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002234 }
2235 if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002236 skip |= LogError(
2237 device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715",
Chris Mayer9ded5eb2019-09-19 16:33:26 +02002238 "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32
2239 "] "
2240 "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.",
2241 i);
2242 }
2243 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002244 }
2245
2246 if (pCreateInfos[i].pMultisampleState == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002247 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751",
2248 "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable "
2249 "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.",
2250 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002251 } else {
Dave Houltonb3bbec72018-01-17 10:13:33 -07002252 const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType,
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002253 LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType,
Dave Houltonb3bbec72018-01-17 10:13:33 -07002254 LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType,
2255 LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType};
Mike Schuchardt97662b02017-12-06 13:31:29 -07002256 const char *valid_struct_names =
Dave Houltona9df0ce2018-02-07 10:51:23 -07002257 "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, "
John Zulauf96b0e422017-11-14 11:43:19 -07002258 "VkPipelineSampleLocationsStateCreateInfoEXT";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002259 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002260 "vkCreateGraphicsPipelines",
John Zulauf96b0e422017-11-14 11:43:19 -07002261 ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}),
Mark Lobodzinski1ddf16f2020-08-13 08:58:13 -06002262 valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes,
sfricke-samsung32a27362020-02-28 09:06:42 -08002263 GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext",
2264 "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002265
2266 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002267 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002268 ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002269 pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002270
2271 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002272 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002273 ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}),
2274 pCreateInfos[i].pMultisampleState->sampleShadingEnable);
2275
2276 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002277 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002278 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2279 ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002280 pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask,
Dave Houlton413a6782018-05-22 13:01:54 -06002281 true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002282
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002283 skip |= validate_flags(
2284 "vkCreateGraphicsPipelines",
2285 ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}),
2286 "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples,
Petr Kraus52758be2019-08-12 00:53:58 +02002287 kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter");
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002288
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002289 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002290 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002291 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}),
2292 pCreateInfos[i].pMultisampleState->alphaToCoverageEnable);
2293
2294 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002295 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002296 ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}),
2297 pCreateInfos[i].pMultisampleState->alphaToOneEnable);
2298
2299 if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002300 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002301 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be "
2302 "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO",
2303 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002304 }
John Zulauf7acac592017-11-06 11:15:53 -07002305 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002306 if (!physical_device_features.sampleRateShading) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002307 skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784",
2308 "vkCreateGraphicsPipelines(): parameter "
2309 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.",
2310 i);
John Zulauf7acac592017-11-06 11:15:53 -07002311 }
2312 // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored
2313 // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE.
2314 if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002315 skip |= LogError(
2316 device,
2317
Dave Houlton413a6782018-05-22 13:01:54 -06002318 "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786",
Mark Lobodzinski88529492018-04-01 10:38:15 -06002319 "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i);
John Zulauf7acac592017-11-06 11:15:53 -07002320 }
2321 }
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002322
2323 const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>(
2324 pCreateInfos[i].pRasterizationState->pNext);
2325
2326 if (line_state) {
2327 if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT ||
2328 line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) {
2329 if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) {
2330 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002331 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2332 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2333 "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.",
2334 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002335 }
2336 if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) {
2337 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002338 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2339 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2340 "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.",
2341 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002342 }
2343 if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) {
2344 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002345 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766",
2346 "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with "
2347 "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.",
2348 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002349 }
2350 }
2351 if (line_state->stippledLineEnable && !has_dynamic_line_stipple) {
2352 if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) {
2353 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002354 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767",
2355 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the "
2356 "range [1,256].",
2357 i, line_state->lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002358 }
2359 }
2360 const auto *line_features =
Tony-LunarG6c3c5452019-12-13 10:37:38 -07002361 lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002362 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2363 (!line_features || !line_features->rectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002364 skip |=
2365 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768",
2366 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2367 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.",
2368 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002369 }
2370 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2371 (!line_features || !line_features->bresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002372 skip |=
2373 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769",
2374 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2375 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.",
2376 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002377 }
2378 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2379 (!line_features || !line_features->smoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002380 skip |=
2381 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770",
2382 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2383 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.",
2384 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002385 }
2386 if (line_state->stippledLineEnable) {
2387 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT &&
2388 (!line_features || !line_features->stippledRectangularLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002389 skip |=
2390 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771",
2391 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2392 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the "
2393 "stippledRectangularLines feature.",
2394 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002395 }
2396 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT &&
2397 (!line_features || !line_features->stippledBresenhamLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002398 skip |=
2399 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772",
2400 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2401 "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the "
2402 "stippledBresenhamLines feature.",
2403 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002404 }
2405 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT &&
2406 (!line_features || !line_features->stippledSmoothLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002407 skip |=
2408 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773",
2409 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2410 "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the "
2411 "stippledSmoothLines feature.",
2412 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002413 }
2414 if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT &&
2415 (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002416 skip |=
2417 LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774",
2418 "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = "
2419 "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the "
2420 "stippledRectangularLines and strictLines features.",
2421 i);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05002422 }
2423 }
2424 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002425 }
2426
Petr Krause91f7a12017-12-14 20:57:36 +01002427 bool uses_color_attachment = false;
2428 bool uses_depthstencil_attachment = false;
2429 {
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002430 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002431 const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass);
2432 if (subpasses_uses_it != renderpasses_states.end()) {
Petr Krause91f7a12017-12-14 20:57:36 +01002433 const auto &subpasses_uses = subpasses_uses_it->second;
2434 if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass))
2435 uses_color_attachment = true;
2436 if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass))
2437 uses_depthstencil_attachment = true;
2438 }
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07002439 lock.unlock();
Petr Krause91f7a12017-12-14 20:57:36 +01002440 }
2441
2442 if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002443 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002444 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002445 ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL,
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002446 pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002447 "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002448
2449 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002450 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002451 ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002452 pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002453
2454 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002455 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002456 ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}),
2457 pCreateInfos[i].pDepthStencilState->depthTestEnable);
2458
2459 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002460 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002461 ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}),
2462 pCreateInfos[i].pDepthStencilState->depthWriteEnable);
2463
2464 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002465 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002466 ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}),
2467 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002468 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002469
2470 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002471 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002472 ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}),
2473 pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable);
2474
2475 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002476 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002477 ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}),
2478 pCreateInfos[i].pDepthStencilState->stencilTestEnable);
2479
2480 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002481 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002482 ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}),
2483 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002484 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002485
2486 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002487 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002488 ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}),
2489 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002490 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002491
2492 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002493 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002494 ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}),
2495 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002496 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002497
2498 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002499 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002500 ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}),
2501 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002502 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002503
2504 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002505 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002506 ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}),
2507 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002508 "VUID-VkStencilOpState-failOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002509
2510 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002511 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002512 ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}),
2513 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002514 "VUID-VkStencilOpState-passOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002515
2516 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002517 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002518 ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}),
2519 "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002520 "VUID-VkStencilOpState-depthFailOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002521
2522 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002523 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002524 ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}),
2525 "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002526 "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002527
2528 if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002529 skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002530 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be "
2531 "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO",
2532 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002533 }
2534 }
2535
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002536 const VkStructureType allowed_structs_VkPipelineColorBlendStateCreateInfo[] = {
2537 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT};
2538
Petr Krause91f7a12017-12-14 20:57:36 +01002539 if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) {
Mark Lobodzinski876d5b52019-08-06 16:32:27 -06002540 skip |= validate_struct_type("vkCreateGraphicsPipelines",
2541 ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}),
2542 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2543 pCreateInfos[i].pColorBlendState,
2544 VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined,
2545 "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType");
2546
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002547 skip |= validate_struct_pnext(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002548 "vkCreateGraphicsPipelines",
Shannon McPherson9b9532b2018-10-24 12:00:09 -06002549 ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}),
2550 "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext,
2551 ARRAY_SIZE(allowed_structs_VkPipelineColorBlendStateCreateInfo),
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002552 allowed_structs_VkPipelineColorBlendStateCreateInfo, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08002553 "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext",
2554 "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002555
2556 skip |= validate_reserved_flags(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002557 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002558 ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}),
Dave Houlton413a6782018-05-22 13:01:54 -06002559 pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002560
2561 skip |= validate_bool32(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002562 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002563 ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}),
2564 pCreateInfos[i].pColorBlendState->logicOpEnable);
2565
2566 skip |= validate_array(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002567 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002568 ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}),
2569 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}),
Gabríel Arthúr Pétursson092b29b2018-03-21 22:44:11 +00002570 pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false,
Dave Houlton413a6782018-05-22 13:01:54 -06002571 true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002572
2573 if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) {
2574 for (uint32_t attachmentIndex = 0; attachmentIndex < pCreateInfos[i].pColorBlendState->attachmentCount;
2575 ++attachmentIndex) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002576 skip |= validate_bool32("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002577 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable",
2578 ParameterName::IndexVector{i, attachmentIndex}),
2579 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].blendEnable);
2580
2581 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002582 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002583 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor",
2584 ParameterName::IndexVector{i, attachmentIndex}),
2585 "VkBlendFactor", AllVkBlendFactorEnums,
2586 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002587 "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002588
2589 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002590 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002591 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor",
2592 ParameterName::IndexVector{i, attachmentIndex}),
2593 "VkBlendFactor", AllVkBlendFactorEnums,
2594 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstColorBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002595 "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002596
2597 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002598 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002599 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp",
2600 ParameterName::IndexVector{i, attachmentIndex}),
2601 "VkBlendOp", AllVkBlendOpEnums,
2602 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002603 "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002604
2605 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002606 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002607 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor",
2608 ParameterName::IndexVector{i, attachmentIndex}),
2609 "VkBlendFactor", AllVkBlendFactorEnums,
2610 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].srcAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002611 "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002612
2613 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002614 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002615 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor",
2616 ParameterName::IndexVector{i, attachmentIndex}),
2617 "VkBlendFactor", AllVkBlendFactorEnums,
2618 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].dstAlphaBlendFactor,
Dave Houlton413a6782018-05-22 13:01:54 -06002619 "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002620
2621 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002622 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002623 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp",
2624 ParameterName::IndexVector{i, attachmentIndex}),
2625 "VkBlendOp", AllVkBlendOpEnums,
2626 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].alphaBlendOp,
Dave Houlton413a6782018-05-22 13:01:54 -06002627 "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002628
2629 skip |=
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002630 validate_flags("vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002631 ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask",
2632 ParameterName::IndexVector{i, attachmentIndex}),
2633 "VkColorComponentFlagBits", AllVkColorComponentFlagBits,
2634 pCreateInfos[i].pColorBlendState->pAttachments[attachmentIndex].colorWriteMask,
Petr Kraus52758be2019-08-12 00:53:58 +02002635 kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002636 }
2637 }
2638
2639 if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) {
sfricke-samsung81c56f72020-08-23 22:14:41 -07002640 skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002641 "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be "
2642 "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO",
2643 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002644 }
2645
2646 // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value
2647 if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) {
2648 skip |= validate_ranged_enum(
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002649 "vkCreateGraphicsPipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002650 ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp",
Dave Houlton413a6782018-05-22 13:01:54 -06002651 AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp,
2652 "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002653 }
2654 }
2655 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002656
Petr Kraus9752aae2017-11-24 03:05:50 +01002657 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
2658 if (pCreateInfos[i].basePipelineIndex != -1) {
2659 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002660 skip |=
2661 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002662 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002663 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002664 "and pCreateInfos->basePipelineIndex is not -1.",
2665 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002666 }
2667 }
2668
Petr Kraus9752aae2017-11-24 03:05:50 +01002669 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
2670 if (pCreateInfos[i].basePipelineIndex != -1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002671 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725",
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002672 "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if "
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002673 "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002674 "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.",
2675 i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002676 }
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002677 } else {
Mike Schuchardte5c15cf2020-04-06 22:57:13 -07002678 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002679 skip |=
2680 LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723",
2681 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid"
2682 "index into the pCreateInfos array, of size %d.",
2683 i, pCreateInfos[i].basePipelineIndex, createInfoCount);
Mark Lobodzinski4dfeb942019-09-13 12:11:13 -06002684 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002685 }
2686 }
2687
sfricke-samsung898cf222020-05-15 23:10:19 -07002688 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) {
2689 skip |= LogError(
2690 device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764",
2691 "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE",
2692 i);
2693 }
2694
Petr Kraus9752aae2017-11-24 03:05:50 +01002695 if (pCreateInfos[i].pRasterizationState) {
Chris Mayer840b2c42019-08-22 18:12:22 +02002696 if (!device_extensions.vk_nv_fill_rectangle) {
2697 if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) {
2698 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002699 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414",
2700 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
2701 "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV "
2702 "if the extension VK_NV_fill_rectangle is not enabled.");
Chris Mayer840b2c42019-08-22 18:12:22 +02002703 } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2704 (physical_device_features.fillModeNonSolid == false)) {
sfricke-samsunga44586f2020-08-23 22:19:44 -07002705 skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002706 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002707 "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or "
2708 "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2709 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002710 }
2711 } else {
2712 if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) &&
2713 (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) &&
2714 (physical_device_features.fillModeNonSolid == false)) {
2715 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002716 LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507",
2717 "vkCreateGraphicsPipelines parameter, VkPolygonMode "
sfricke-samsunga470e0e2020-05-16 00:47:36 -07002718 "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or "
2719 "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.",
2720 i);
Chris Mayer840b2c42019-08-22 18:12:22 +02002721 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002722 }
Petr Kraus299ba622017-11-24 03:09:03 +01002723
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002724 if (!has_dynamic_line_width && !physical_device_features.wideLines &&
Petr Kraus299ba622017-11-24 03:09:03 +01002725 (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002726 skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749",
2727 "The line width state is static (pCreateInfos[%" PRIu32
2728 "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and "
2729 "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32
2730 "].pRasterizationState->lineWidth (=%f) is not 1.0.",
2731 i, i, pCreateInfos[i].pRasterizationState->lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01002732 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002733 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002734 }
2735 }
2736
2737 return skip;
2738}
2739
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002740bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache,
2741 uint32_t createInfoCount,
2742 const VkComputePipelineCreateInfo *pCreateInfos,
2743 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002744 VkPipeline *pPipelines) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002745 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002746 for (uint32_t i = 0; i < createInfoCount; i++) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002747 skip |= validate_string("vkCreateComputePipelines",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002748 ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}),
Mark Lobodzinskiebee3552018-05-29 09:55:54 -06002749 "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName);
Peter Chen85366392019-05-14 15:20:11 -04002750 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
2751 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002752 skip |=
2753 LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669",
2754 "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32
2755 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".",
2756 i, feedback_struct->pipelineStageCreationFeedbackCount);
Peter Chen85366392019-05-14 15:20:11 -04002757 }
sfricke-samsungc5227152020-02-09 17:36:31 -08002758
2759 // Make sure compute stage is selected
2760 if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002761 skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701",
2762 "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT",
2763 i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage));
sfricke-samsungc5227152020-02-09 17:36:31 -08002764 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002765 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002766 return skip;
2767}
2768
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002769bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002770 const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002771 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002772
2773 if (pCreateInfo != nullptr) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002774 const auto &features = physical_device_features;
2775 const auto &limits = device_limits;
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002776
John Zulauf71968502017-10-26 13:51:15 -06002777 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
2778 if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002779 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071",
2780 "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.",
2781 "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy,
2782 "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy);
John Zulauf71968502017-10-26 13:51:15 -06002783 }
2784
2785 // Anistropy cannot be enabled in sampler unless enabled as a feature
2786 if (features.samplerAnisotropy == VK_FALSE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002787 skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070",
2788 "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.",
2789 "pCreateInfo->anisotropyEnable");
John Zulauf71968502017-10-26 13:51:15 -06002790 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002791 }
John Zulauf71968502017-10-26 13:51:15 -06002792
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002793 if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) {
2794 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002795 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072",
2796 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2797 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2798 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002799 }
2800 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002801 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073",
2802 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2803 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2804 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002805 }
2806 if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002807 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074",
2808 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2809 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.",
2810 pCreateInfo->minLod, pCreateInfo->maxLod);
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002811 }
2812 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2813 pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2814 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE &&
2815 pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002816 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075",
2817 "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, "
2818 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be "
2819 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.",
2820 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2821 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002822 }
2823 if (pCreateInfo->anisotropyEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002824 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076",
2825 "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must "
2826 "not both be VK_TRUE.");
John Zulauf71968502017-10-26 13:51:15 -06002827 }
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002828 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002829 skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077",
2830 "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must "
2831 "not both be VK_TRUE.");
Jesse Hallcc1fbef2018-06-03 15:58:56 -07002832 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002833 }
2834
2835 // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value
2836 if (pCreateInfo->compareEnable == VK_TRUE) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002837 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums,
2838 pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080");
sfricke-samsung85252fb2020-05-08 20:44:06 -07002839 const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext);
2840 if (sampler_reduction != nullptr) {
2841 if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) {
2842 skip |= LogError(
2843 device, "VUID-VkSamplerCreateInfo-compareEnable-01423",
2844 "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE.");
2845 }
2846 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002847 }
2848
2849 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a
2850 // valid VkBorderColor value
2851 if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2852 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) ||
2853 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002854 skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums,
2855 pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002856 }
2857
2858 // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the
2859 // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002860 if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge &&
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002861 ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2862 (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) ||
2863 (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) {
Dave Houlton413a6782018-05-22 13:01:54 -06002864 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002865 LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079",
2866 "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE "
2867 "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002868 }
John Zulauf275805c2017-10-26 15:34:49 -06002869
2870 // Checks for the IMG cubic filtering extension
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07002871 if (device_extensions.vk_img_filter_cubic) {
John Zulauf275805c2017-10-26 15:34:49 -06002872 if ((pCreateInfo->anisotropyEnable == VK_TRUE) &&
2873 ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002874 skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081",
2875 "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter "
2876 "are VK_FILTER_CUBIC_IMG.");
John Zulauf275805c2017-10-26 15:34:49 -06002877 }
2878 }
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002879
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002880 // Check for valid Lod range
2881 if (pCreateInfo->minLod > pCreateInfo->maxLod) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002882 skip |=
2883 LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973",
2884 "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002885 }
2886
2887 // Check mipLodBias to device limit
2888 if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) {
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002889 skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069",
2890 "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)",
2891 pCreateInfo->mipLodBias, limits.maxSamplerLodBias);
sfricke-samsungd91da4a2020-02-09 17:19:04 -08002892 }
2893
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002894 const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext);
2895 if (sampler_conversion != nullptr) {
2896 if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2897 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2898 (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) ||
2899 (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07002900 skip |= LogError(
Mark Lobodzinski728ab482020-02-12 13:46:47 -07002901 device, "VUID-VkSamplerCreateInfo-addressModeU-01646",
Mark Lobodzinski61992fc2020-01-14 14:00:08 -07002902 "vkCreateSampler(): SamplerYCbCrConversion is enabled: "
2903 "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) "
2904 "and unnormalizedCoordinates (%s) must be VK_FALSE.",
2905 string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV),
2906 string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE",
2907 pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE");
2908 }
2909 }
janharaldfredriksen-arm3b793772020-05-12 18:55:53 +02002910
2911 if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) {
2912 if (pCreateInfo->minFilter != pCreateInfo->magFilter) {
2913 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574",
2914 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2915 "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.",
2916 string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter));
2917 }
2918 if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) {
2919 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575",
2920 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2921 "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.",
2922 string_VkSamplerMipmapMode(pCreateInfo->mipmapMode));
2923 }
2924 if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) {
2925 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576",
2926 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2927 "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.",
2928 pCreateInfo->minLod, pCreateInfo->maxLod);
2929 }
2930 if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2931 (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) ||
2932 ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) &&
2933 (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) {
2934 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577",
2935 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2936 "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be "
2937 "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER",
2938 string_VkSamplerAddressMode(pCreateInfo->addressModeU),
2939 string_VkSamplerAddressMode(pCreateInfo->addressModeV));
2940 }
2941 if (pCreateInfo->anisotropyEnable) {
2942 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578",
2943 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2944 "pCreateInfo->anisotropyEnable must be VK_FALSE");
2945 }
2946 if (pCreateInfo->compareEnable) {
2947 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579",
2948 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2949 "pCreateInfo->compareEnable must be VK_FALSE");
2950 }
2951 if (pCreateInfo->unnormalizedCoordinates) {
2952 skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580",
2953 "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, "
2954 "pCreateInfo->unnormalizedCoordinates must be VK_FALSE");
2955 }
2956 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002957 }
2958
Tony-LunarG7337b312020-04-15 16:40:25 -06002959 if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT ||
2960 pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) {
2961 if (!device_extensions.vk_ext_custom_border_color) {
2962 skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled,
2963 "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n",
2964 string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME);
2965 }
2966 auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext);
2967 if (!custom_create_info) {
2968 skip |=
2969 LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011",
2970 "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT "
2971 "struct in pNext chain.\n",
2972 string_VkBorderColor(pCreateInfo->borderColor));
2973 } else {
2974 if ((custom_create_info->format != VK_FORMAT_UNDEFINED) &&
2975 ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) ||
2976 (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT &&
2977 !FormatIsSampledFloat(custom_create_info->format)))) {
2978 skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013",
2979 "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s "
2980 "whose type does not match\n",
2981 string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format));
2982 ;
2983 }
2984 }
2985 }
2986
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002987 return skip;
2988}
2989
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07002990bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device,
2991 const VkDescriptorSetLayoutCreateInfo *pCreateInfo,
2992 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05002993 VkDescriptorSetLayout *pSetLayout) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002994 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06002995
2996 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
2997 if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) {
2998 for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) {
2999 if (pCreateInfo->pBindings[i].descriptorCount != 0) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003000 if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3001 (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) &&
3002 (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) {
3003 for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount;
3004 ++descriptor_index) {
3005 if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) {
Spencer Frickeb0e30822020-03-23 10:32:30 -07003006 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003007 "vkCreateDescriptorSetLayout: required parameter "
3008 "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE",
3009 i, descriptor_index);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003010 }
3011 }
3012 }
3013
3014 // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values
3015 if ((pCreateInfo->pBindings[i].stageFlags != 0) &&
3016 ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003017 skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283",
3018 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, "
3019 "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits "
3020 "values.",
3021 i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003022 }
Spencer Fricke84d0cc02020-03-16 17:21:59 -07003023
3024 if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) &&
3025 (pCreateInfo->pBindings[i].stageFlags != 0) &&
3026 (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) {
3027 skip |=
3028 LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510",
3029 "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and "
3030 "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags "
3031 "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s",
3032 i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str());
3033 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003034 }
3035 }
3036 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003037 return skip;
3038}
3039
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003040bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool,
3041 uint32_t descriptorSetCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003042 const VkDescriptorSet *pDescriptorSets) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003043 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3044 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3045 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003046 return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets,
3047 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003048}
3049
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003050bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount,
3051 const VkWriteDescriptorSet *pDescriptorWrites,
3052 const bool validateDstSet) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003053 bool skip = false;
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003054
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003055 if (pDescriptorWrites != NULL) {
3056 for (uint32_t i = 0; i < descriptorWriteCount; ++i) {
3057 // descriptorCount must be greater than 0
3058 if (pDescriptorWrites[i].descriptorCount == 0) {
3059 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003060 LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength",
3061 "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003062 }
3063
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003064 // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored.
3065 if (validateDstSet) {
3066 // dstSet must be a valid VkDescriptorSet handle
3067 skip |= validate_required_handle(vkCallingFunction,
3068 ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}),
3069 pDescriptorWrites[i].dstSet);
3070 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003071
3072 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) ||
3073 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) ||
3074 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) ||
3075 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) ||
3076 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) {
3077 // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER,
3078 // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT,
Jeff Bolz165818a2020-05-08 11:19:03 -05003079 // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures.
3080 // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003081 if (pDescriptorWrites[i].pImageInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003082 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322",
3083 "%s(): if pDescriptorWrites[%d].descriptorType is "
3084 "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, "
3085 "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or "
3086 "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.",
3087 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003088 } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) {
3089 // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE,
Jeff Bolz165818a2020-05-08 11:19:03 -05003090 // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout
3091 // member of any given element of pImageInfo must be a valid VkImageLayout
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003092 for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount;
3093 ++descriptor_index) {
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003094 skip |= validate_ranged_enum(vkCallingFunction,
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003095 ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout",
3096 ParameterName::IndexVector{i, descriptor_index}),
3097 "VkImageLayout", AllVkImageLayoutEnums,
Dave Houlton413a6782018-05-22 13:01:54 -06003098 pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003099 }
3100 }
3101 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3102 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3103 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) ||
3104 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
3105 // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER,
3106 // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a
3107 // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures
Jeff Bolz165818a2020-05-08 11:19:03 -05003108 // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003109 if (pDescriptorWrites[i].pBufferInfo == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003110 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324",
3111 "%s(): if pDescriptorWrites[%d].descriptorType is "
3112 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, "
3113 "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, "
3114 "pDescriptorWrites[%d].pBufferInfo must not be NULL.",
3115 vkCallingFunction, i, i);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003116 } else {
Jeff Bolz165818a2020-05-08 11:19:03 -05003117 const auto *robustness2_features =
3118 lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
3119 if (robustness2_features && robustness2_features->nullDescriptor) {
3120 for (uint32_t descriptorIndex = 0; descriptorIndex < pDescriptorWrites[i].descriptorCount;
3121 ++descriptorIndex) {
3122 if (pDescriptorWrites[i].pBufferInfo[descriptorIndex].buffer == VK_NULL_HANDLE &&
3123 (pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset != 0 ||
3124 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range != VK_WHOLE_SIZE)) {
3125 skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999",
3126 "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, "
baldurk751594b2020-09-09 09:41:02 +01003127 "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.",
Jeff Bolz165818a2020-05-08 11:19:03 -05003128 vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptorIndex].offset,
3129 pDescriptorWrites[i].pBufferInfo[descriptorIndex].range);
3130 }
3131 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003132 }
3133 }
3134 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) ||
3135 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) {
Jeff Bolz165818a2020-05-08 11:19:03 -05003136 // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite.
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003137 }
3138
3139 if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) ||
3140 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003141 VkDeviceSize uniformAlignment = device_limits.minUniformBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003142 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3143 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3144 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003145 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003146 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327",
3147 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3148 ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3149 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniformAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003150 }
3151 }
3152 }
3153 } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) ||
3154 (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003155 VkDeviceSize storageAlignment = device_limits.minStorageBufferOffsetAlignment;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003156 for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) {
3157 if (pDescriptorWrites[i].pBufferInfo != NULL) {
3158 if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment) != 0) {
Mark Lobodzinski88529492018-04-01 10:38:15 -06003159 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003160 LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328",
3161 "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64
3162 ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".",
3163 vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storageAlignment);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003164 }
3165 }
3166 }
3167 }
sourav parmara96ab1a2020-04-25 16:28:23 -07003168 // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR
3169 // or VkWriteDescriptorSetInlineUniformBlockEX
3170 if (pDescriptorWrites[i].pNext) {
3171 if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003172 const auto *pnext_struct =
sourav parmara96ab1a2020-04-25 16:28:23 -07003173 lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext);
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003174 if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003175 skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382",
3176 "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext"
3177 "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose "
3178 "accelerationStructureCount %d member equals descriptorCount %d.",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003179 vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1,
sourav parmara96ab1a2020-04-25 16:28:23 -07003180 pDescriptorWrites[i].descriptorCount);
3181 }
3182 // further checks only if we have right structtype
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003183 if (pnext_struct) {
3184 if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003185 skip |= LogError(
3186 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236",
3187 "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure "
3188 ".",
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003189 vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount);
sourav parmara96ab1a2020-04-25 16:28:23 -07003190 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06003191 if (pnext_struct->accelerationStructureCount == 0) {
sourav parmara96ab1a2020-04-25 16:28:23 -07003192 skip |= LogError(
3193 device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength",
3194 "%s(): accelerationStructureCount must be greater than 0 .");
3195 }
3196 }
3197 }
3198 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003199 }
3200 }
3201 return skip;
3202}
3203
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003204bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount,
3205 const VkWriteDescriptorSet *pDescriptorWrites,
3206 uint32_t descriptorCopyCount,
3207 const VkCopyDescriptorSet *pDescriptorCopies) const {
3208 return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites);
3209}
3210
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003211bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003212 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003213 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003214 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1);
3215}
3216
sfricke-samsung681ab7b2020-10-29 01:53:35 -07003217bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo,
3218 const VkAllocationCallbacks *pAllocator,
3219 VkRenderPass *pRenderPass) const {
3220 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3221}
3222
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003223bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003224 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003225 VkRenderPass *pRenderPass) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003226 return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2);
3227}
3228
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003229bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool,
3230 uint32_t commandBufferCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003231 const VkCommandBuffer *pCommandBuffers) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003232 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003233
3234 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3235 // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond
3236 // validate_array()
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003237 skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers,
3238 true, true, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003239 return skip;
3240}
3241
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003242bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003243 const VkCommandBufferBeginInfo *pBeginInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003244 bool skip = false;
Petr Krause7bb9e82019-08-11 21:34:43 +02003245
3246 // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer
3247 const char *cmd_name = "vkBeginCommandBuffer";
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003248 const VkCommandBufferInheritanceInfo *pInfo = pBeginInfo->pInheritanceInfo;
3249
Petr Krause7bb9e82019-08-11 21:34:43 +02003250 // Implicit VUs
3251 // validate only sType here; pointer has to be validated in core_validation
3252 const bool kNotRequired = false;
3253 const char *kNoVUID = nullptr;
3254 skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO",
3255 pInfo, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, kNotRequired, kNoVUID,
3256 "VUID-VkCommandBufferInheritanceInfo-sType-sType");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003257
Petr Krause7bb9e82019-08-11 21:34:43 +02003258 if (pInfo) {
3259 const VkStructureType allowed_structs_VkCommandBufferInheritanceInfo[] = {
3260 VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT};
3261 skip |= validate_struct_pnext(
3262 cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", pInfo->pNext,
3263 ARRAY_SIZE(allowed_structs_VkCommandBufferInheritanceInfo), allowed_structs_VkCommandBufferInheritanceInfo,
sfricke-samsung32a27362020-02-28 09:06:42 -08003264 GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext",
3265 "VUID-VkCommandBufferInheritanceInfo-sType-unique");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003266
Petr Krause7bb9e82019-08-11 21:34:43 +02003267 skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", pInfo->occlusionQueryEnable);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003268
Petr Krause7bb9e82019-08-11 21:34:43 +02003269 // Explicit VUs
3270 if (!physical_device_features.inheritedQueries && pInfo->occlusionQueryEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003271 skip |= LogError(
3272 commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056",
Petr Krause7bb9e82019-08-11 21:34:43 +02003273 "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.",
3274 cmd_name);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003275 }
Petr Krause7bb9e82019-08-11 21:34:43 +02003276
3277 if (physical_device_features.inheritedQueries) {
3278 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003279 AllVkQueryControlFlagBits, pInfo->queryFlags, kOptionalFlags,
Dave Houlton413a6782018-05-22 13:01:54 -06003280 "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057");
Petr Krause7bb9e82019-08-11 21:34:43 +02003281 } else { // !inheritedQueries
Petr Krause7bb9e82019-08-11 21:34:43 +02003282 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", pInfo->queryFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003283 "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788");
Petr Krause7bb9e82019-08-11 21:34:43 +02003284 }
3285
3286 if (physical_device_features.pipelineStatisticsQuery) {
Petr Krause7bb9e82019-08-11 21:34:43 +02003287 skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits",
Petr Kraus52758be2019-08-12 00:53:58 +02003288 AllVkQueryPipelineStatisticFlagBits, pInfo->pipelineStatistics, kOptionalFlags,
Petr Kraus43aed2c2019-08-18 13:59:16 +02003289 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789");
Petr Krause7bb9e82019-08-11 21:34:43 +02003290 } else { // !pipelineStatisticsQuery
3291 skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", pInfo->pipelineStatistics,
3292 "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003293 }
Petr Kraus139757b2019-08-15 17:19:33 +02003294
3295 const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(pInfo->pNext);
3296 if (conditional_rendering) {
Tony-LunarG6c3c5452019-12-13 10:37:38 -07003297 const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext);
Petr Kraus139757b2019-08-15 17:19:33 +02003298 const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering;
3299 if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003300 skip |= LogError(
3301 commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977",
Petr Kraus139757b2019-08-15 17:19:33 +02003302 "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but "
3303 "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE.");
3304 }
3305 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003306 }
3307
3308 return skip;
3309}
3310
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003311bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003312 uint32_t viewportCount, const VkViewport *pViewports) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003313 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003314
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003315 if (!physical_device_features.multiViewport) {
Petr Krausd55e77c2018-01-09 22:09:25 +01003316 if (firstViewport != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003317 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224",
3318 "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.",
3319 firstViewport);
Petr Krausd55e77c2018-01-09 22:09:25 +01003320 }
3321 if (viewportCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003322 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225",
3323 "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.",
3324 viewportCount);
Petr Krausd55e77c2018-01-09 22:09:25 +01003325 }
3326 } else { // multiViewport enabled
Petr Kraus7dfeed12018-02-27 20:51:20 +01003327 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003328 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003329 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223",
3330 "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3331 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3332 firstViewport, viewportCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003333 }
3334 }
Petr Krausb3fcdb42018-01-09 22:09:09 +01003335
3336 if (pViewports) {
3337 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
3338 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
Jeff Bolz6d3beaa2019-02-09 21:00:05 -06003339 const char *fn_name = "vkCmdSetViewport";
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003340 skip |= manual_PreCallValidateViewport(
3341 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
Petr Krausb3fcdb42018-01-09 22:09:09 +01003342 }
3343 }
3344
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003345 return skip;
3346}
3347
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003348bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003349 uint32_t scissorCount, const VkRect2D *pScissors) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003350 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003351
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003352 if (!physical_device_features.multiViewport) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003353 if (firstScissor != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003354 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593",
3355 "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.",
3356 firstScissor);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003357 }
3358 if (scissorCount > 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003359 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594",
3360 "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.",
3361 scissorCount);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003362 }
3363 } else { // multiViewport enabled
3364 const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003365 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003366 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592",
3367 "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3368 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3369 firstScissor, scissorCount, sum, device_limits.maxViewports);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003370 }
3371 }
3372
Petr Kraus6260f0a2018-02-27 21:15:55 +01003373 if (pScissors) {
3374 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
3375 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003376
Petr Kraus6260f0a2018-02-27 21:15:55 +01003377 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003378 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3379 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
3380 scissor.offset.x);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003381 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003382
Petr Kraus6260f0a2018-02-27 21:15:55 +01003383 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003384 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595",
3385 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
3386 scissor.offset.y);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003387 }
3388
3389 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3390 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003391 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596",
3392 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3393 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3394 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003395 }
3396
3397 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3398 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003399 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597",
3400 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3401 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3402 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Petr Kraus6260f0a2018-02-27 21:15:55 +01003403 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003404 }
3405 }
Petr Kraus6260f0a2018-02-27 21:15:55 +01003406
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003407 return skip;
3408}
3409
Jeff Bolz5c801d12019-10-09 10:38:45 -05003410bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const {
Petr Kraus299ba622017-11-24 03:09:03 +01003411 bool skip = false;
Petr Kraus299ba622017-11-24 03:09:03 +01003412
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003413 if (!physical_device_features.wideLines && (lineWidth != 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003414 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788",
3415 "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth);
Petr Kraus299ba622017-11-24 03:09:03 +01003416 }
3417
3418 return skip;
3419}
3420
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003421bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003422 uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003423 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003424
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003425 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003426 skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003427 "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003428 }
3429 return skip;
3430}
3431
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003432bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003433 VkDeviceSize offset, uint32_t count, uint32_t stride) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003434 bool skip = false;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003435 if (!physical_device_features.multiDrawIndirect && ((count > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003436 skip |=
Mark Lobodzinski41ce65b2020-10-30 12:17:06 -06003437 LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003438 "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", count);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003439 }
3440 return skip;
3441}
3442
sfricke-samsungf692b972020-05-02 08:00:45 -07003443bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3444 VkDeviceSize countBufferOffset, bool khr) const {
3445 bool skip = false;
3446 const char *apiName = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()";
3447 if (offset & 3) {
3448 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710",
3449 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3450 }
3451
3452 if (countBufferOffset & 3) {
3453 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716",
3454 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3455 countBufferOffset);
3456 }
3457 return skip;
3458}
3459
3460bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3461 VkDeviceSize offset, VkBuffer countBuffer,
3462 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3463 uint32_t stride) const {
3464 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false);
3465}
3466
3467bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3468 VkDeviceSize offset, VkBuffer countBuffer,
3469 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3470 uint32_t stride) const {
3471 return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true);
3472}
3473
3474bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset,
3475 VkDeviceSize countBufferOffset, bool khr) const {
3476 bool skip = false;
3477 const char *apiName = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()";
3478 if (offset & 3) {
3479 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710",
3480 "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName, offset);
3481 }
3482
3483 if (countBufferOffset & 3) {
3484 skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716",
3485 "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", apiName,
3486 countBufferOffset);
3487 }
3488 return skip;
3489}
3490
3491bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer,
3492 VkDeviceSize offset, VkBuffer countBuffer,
3493 VkDeviceSize countBufferOffset, uint32_t maxDrawCount,
3494 uint32_t stride) const {
3495 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false);
3496}
3497
3498bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer,
3499 VkDeviceSize offset, VkBuffer countBuffer,
3500 VkDeviceSize countBufferOffset,
3501 uint32_t maxDrawCount, uint32_t stride) const {
3502 return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true);
3503}
3504
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003505bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount,
3506 const VkClearAttachment *pAttachments, uint32_t rectCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003507 const VkClearRect *pRects) const {
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003508 bool skip = false;
3509 for (uint32_t rect = 0; rect < rectCount; rect++) {
3510 if (pRects[rect].layerCount == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003511 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934",
3512 "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect);
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003513 }
sfricke-samsung10867682020-04-25 02:20:39 -07003514 if (pRects[rect].rect.extent.width == 0) {
3515 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682",
3516 "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect);
3517 }
3518 if (pRects[rect].rect.extent.height == 0) {
3519 skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683",
3520 "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect);
3521 }
Mark Lobodzinskif77a4ac2019-06-27 15:30:51 -06003522 }
3523 return skip;
3524}
3525
Andrew Fobel3abeb992020-01-20 16:33:22 -05003526bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice,
3527 const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3528 VkImageFormatProperties2 *pImageFormatProperties,
3529 const char *apiName) const {
3530 bool skip = false;
3531
3532 if (pImageFormatInfo != nullptr) {
3533 const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfoEXT>(pImageFormatInfo->pNext);
3534 if (image_stencil_struct != nullptr) {
3535 if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) {
3536 VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT);
3537 // No flags other than the legal attachment bits may be set
3538 legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT;
3539 if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003540 skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539",
3541 "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage "
3542 "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than "
3543 "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT",
3544 apiName);
Andrew Fobel3abeb992020-01-20 16:33:22 -05003545 }
3546 }
3547 }
3548 }
3549
3550 return skip;
3551}
3552
3553bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2(
3554 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3555 VkImageFormatProperties2 *pImageFormatProperties) const {
3556 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3557 "vkGetPhysicalDeviceImageFormatProperties2");
3558}
3559
3560bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR(
3561 VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo,
3562 VkImageFormatProperties2 *pImageFormatProperties) const {
3563 return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties,
3564 "vkGetPhysicalDeviceImageFormatProperties2KHR");
3565}
3566
sfricke-samsung3999ef62020-02-09 17:05:59 -08003567bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer,
3568 uint32_t regionCount, const VkBufferCopy *pRegions) const {
3569 bool skip = false;
3570
3571 if (pRegions != nullptr) {
3572 for (uint32_t i = 0; i < regionCount; i++) {
3573 if (pRegions[i].size == 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003574 skip |= LogError(device, "VUID-VkBufferCopy-size-01988",
3575 "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i);
sfricke-samsung3999ef62020-02-09 17:05:59 -08003576 }
3577 }
3578 }
3579 return skip;
3580}
3581
Jeff Leger178b1e52020-10-05 12:22:23 -04003582bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer,
3583 const VkCopyBufferInfo2KHR *pCopyBufferInfo) const {
3584 bool skip = false;
3585
3586 if (pCopyBufferInfo->pRegions != nullptr) {
3587 for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) {
3588 if (pCopyBufferInfo->pRegions[i].size == 0) {
3589 skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988",
3590 "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i);
3591 }
3592 }
3593 }
3594 return skip;
3595}
3596
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003597bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003598 VkDeviceSize dstOffset, VkDeviceSize dataSize,
3599 const void *pData) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003600 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003601
3602 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003603 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036",
3604 "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3605 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003606 }
3607
3608 if ((dataSize <= 0) || (dataSize > 65536)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003609 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037",
3610 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64
3611 "), must be greater than zero and less than or equal to 65536.",
3612 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003613 } else if (dataSize & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003614 skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038",
3615 "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3616 dataSize);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003617 }
3618 return skip;
3619}
3620
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003621bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003622 VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003623 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003624
3625 if (dstOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003626 skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025",
3627 "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.",
3628 dstOffset);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003629 }
3630
3631 if (size != VK_WHOLE_SIZE) {
3632 if (size <= 0) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003633 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003634 LogError(device, "VUID-vkCmdFillBuffer-size-00026",
3635 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003636 } else if (size & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003637 skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028",
3638 "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003639 }
3640 }
3641 return skip;
3642}
3643
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003644bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003645 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003646 VkSwapchainKHR *pSwapchain) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003647 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003648
3649 if (pCreateInfo != nullptr) {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003650 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
3651 if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) {
3652 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1
3653 if (pCreateInfo->queueFamilyIndexCount <= 1) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003654 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278",
3655 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3656 "pCreateInfo->queueFamilyIndexCount must be greater than 1.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003657 }
3658
3659 // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of
3660 // queueFamilyIndexCount uint32_t values
3661 if (pCreateInfo->pQueueFamilyIndices == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003662 skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277",
3663 "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, "
3664 "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of "
3665 "pCreateInfo->queueFamilyIndexCount uint32_t values.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003666 }
3667 }
3668
Dave Houlton413a6782018-05-22 13:01:54 -06003669 skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003670 "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003671 }
3672
3673 return skip;
3674}
3675
Jeff Bolz5c801d12019-10-09 10:38:45 -05003676bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003677 bool skip = false;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003678
3679 if (pPresentInfo && pPresentInfo->pNext) {
John Zulaufde972ac2017-10-26 12:07:05 -06003680 const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext);
3681 if (present_regions) {
3682 // TODO: This and all other pNext extension dependencies should be added to code-generation
Tony-LunarG2ec96bb2019-11-26 13:43:02 -07003683 skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR",
John Zulaufde972ac2017-10-26 12:07:05 -06003684 VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME);
3685 if (present_regions->swapchainCount != pPresentInfo->swapchainCount) {
sfricke-samsunga4cc4ff2020-08-23 22:05:49 -07003686 skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003687 "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR "
3688 "extension swapchainCount is %i. These values must be equal.",
3689 pPresentInfo->swapchainCount, present_regions->swapchainCount);
John Zulaufde972ac2017-10-26 12:07:05 -06003690 }
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003691 skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL,
sfricke-samsung32a27362020-02-28 09:06:42 -08003692 GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext",
3693 "VUID-VkPresentInfoKHR-sType-unique");
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003694 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions",
3695 present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined,
3696 kVUIDUndefined);
John Zulaufde972ac2017-10-26 12:07:05 -06003697 for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003698 skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount",
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003699 "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount,
Dave Houlton413a6782018-05-22 13:01:54 -06003700 &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003701 }
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003702 }
3703 }
3704
3705 return skip;
3706}
3707
3708#ifdef VK_USE_PLATFORM_WIN32_KHR
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003709bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance,
3710 const VkWin32SurfaceCreateInfoKHR *pCreateInfo,
3711 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003712 VkSurfaceKHR *pSurface) const {
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003713 bool skip = false;
3714
3715 if (pCreateInfo->hwnd == nullptr) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003716 skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308",
3717 "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL.");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06003718 }
3719
3720 return skip;
3721}
3722#endif // VK_USE_PLATFORM_WIN32_KHR
3723
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003724bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo,
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003725 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003726 VkDescriptorPool *pDescriptorPool) const {
Petr Krausc8655be2017-09-27 18:56:51 +02003727 bool skip = false;
3728
3729 if (pCreateInfo) {
3730 if (pCreateInfo->maxSets <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003731 skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301",
3732 "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0.");
Petr Krausc8655be2017-09-27 18:56:51 +02003733 }
3734
3735 if (pCreateInfo->pPoolSizes) {
3736 for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) {
3737 if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003738 skip |= LogError(
3739 device, "VUID-VkDescriptorPoolSize-descriptorCount-00302",
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003740 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i);
Petr Krausc8655be2017-09-27 18:56:51 +02003741 }
Jeff Bolze54ae892018-09-08 12:16:29 -05003742 if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT &&
3743 (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003744 skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218",
3745 "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32
3746 "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT "
3747 " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.",
3748 i, i);
Jeff Bolze54ae892018-09-08 12:16:29 -05003749 }
Petr Krausc8655be2017-09-27 18:56:51 +02003750 }
3751 }
3752 }
3753
3754 return skip;
3755}
3756
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003757bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003758 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003759 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003760
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003761 if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003762 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003763 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386",
3764 "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3765 groupCountX, device_limits.maxComputeWorkGroupCount[0]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003766 }
3767
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003768 if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003769 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003770 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387",
3771 "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3772 groupCountY, device_limits.maxComputeWorkGroupCount[1]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003773 }
3774
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003775 if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) {
Mark Lobodzinski487a0d12018-03-30 10:09:03 -06003776 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003777 LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388",
3778 "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3779 groupCountZ, device_limits.maxComputeWorkGroupCount[2]);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003780 }
3781
3782 return skip;
3783}
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003784
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003785bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003786 VkDeviceSize offset) const {
John Zulaufa999d1b2018-11-29 13:38:40 -07003787 bool skip = false;
John Zulaufa999d1b2018-11-29 13:38:40 -07003788
3789 if ((offset % 4) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003790 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710",
3791 "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset);
John Zulaufa999d1b2018-11-29 13:38:40 -07003792 }
3793 return skip;
3794}
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003795
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003796bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX,
3797 uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003798 uint32_t groupCountY, uint32_t groupCountZ) const {
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003799 bool skip = false;
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003800
3801 // Paired if {} else if {} tests used to avoid any possible uint underflow
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003802 uint32_t limit = device_limits.maxComputeWorkGroupCount[0];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003803 if (baseGroupX >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003804 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421",
3805 "vkCmdDispatch(): baseGroupX (%" PRIu32
3806 ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3807 baseGroupX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003808 } else if (groupCountX > (limit - baseGroupX)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003809 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424",
3810 "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32
3811 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").",
3812 baseGroupX, groupCountX, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003813 }
3814
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003815 limit = device_limits.maxComputeWorkGroupCount[1];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003816 if (baseGroupY >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003817 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422",
3818 "vkCmdDispatch(): baseGroupY (%" PRIu32
3819 ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3820 baseGroupY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003821 } else if (groupCountY > (limit - baseGroupY)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003822 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425",
3823 "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32
3824 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").",
3825 baseGroupY, groupCountY, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003826 }
3827
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003828 limit = device_limits.maxComputeWorkGroupCount[2];
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003829 if (baseGroupZ >= limit) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003830 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423",
3831 "vkCmdDispatch(): baseGroupZ (%" PRIu32
3832 ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3833 baseGroupZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003834 } else if (groupCountZ > (limit - baseGroupZ)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003835 skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426",
3836 "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32
3837 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").",
3838 baseGroupZ, groupCountZ, limit);
Dave Houltonbb7d3fe2018-01-11 17:09:16 -07003839 }
3840
3841 return skip;
3842}
3843
Jeremy Hayes390ff6f2020-02-10 13:48:57 -07003844bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer,
3845 VkPipelineBindPoint pipelineBindPoint,
3846 VkPipelineLayout layout, uint32_t set,
3847 uint32_t descriptorWriteCount,
3848 const VkWriteDescriptorSet *pDescriptorWrites) const {
3849 return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false);
3850}
3851
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003852bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer,
3853 uint32_t firstExclusiveScissor,
3854 uint32_t exclusiveScissorCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003855 const VkRect2D *pExclusiveScissors) const {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003856 bool skip = false;
3857
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003858 if (!physical_device_features.multiViewport) {
Jeff Bolz3e71f782018-08-29 23:15:45 -05003859 if (firstExclusiveScissor != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003860 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003861 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035",
3862 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32
3863 ") is not 0.",
3864 firstExclusiveScissor);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003865 }
3866 if (exclusiveScissorCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003867 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003868 LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036",
3869 "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32
3870 ") is not 1.",
3871 exclusiveScissorCount);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003872 }
3873 } else { // multiViewport enabled
3874 const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003875 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003876 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034",
3877 "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32
3878 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3879 firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003880 }
3881 }
3882
Jeff Bolz3e71f782018-08-29 23:15:45 -05003883 if (pExclusiveScissors) {
3884 for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) {
3885 const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr
3886
3887 if (scissor.offset.x < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003888 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3889 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.",
3890 scissor_i, scissor.offset.x);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003891 }
3892
3893 if (scissor.offset.y < 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003894 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037",
3895 "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.",
3896 scissor_i, scissor.offset.y);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003897 }
3898
3899 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
3900 if (x_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003901 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038",
3902 "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3903 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3904 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003905 }
3906
3907 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
3908 if (y_sum > INT32_MAX) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003909 skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039",
3910 "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
3911 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
3912 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
Jeff Bolz3e71f782018-08-29 23:15:45 -05003913 }
3914 }
3915 }
3916
3917 return skip;
3918}
3919
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003920bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport,
3921 uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003922 const VkViewportWScalingNV *pViewportWScalings) const {
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003923 bool skip = false;
Shannon McPherson169d0c72020-11-13 18:48:19 -07003924 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
3925 if ((sum < 1) || (sum > device_limits.maxViewports)) {
3926 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324",
3927 "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64
3928 ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.",
3929 firstViewport, viewportCount, sum, device_limits.maxViewports);
Chris Mayer9ded5eb2019-09-19 16:33:26 +02003930 }
3931
3932 return skip;
3933}
3934
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003935bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV(
3936 VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003937 const VkShadingRatePaletteNV *pShadingRatePalettes) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003938 bool skip = false;
3939
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003940 if (!physical_device_features.multiViewport) {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003941 if (firstViewport != 0) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003942 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003943 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068",
3944 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32
3945 ") is not 0.",
3946 firstViewport);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003947 }
3948 if (viewportCount > 1) {
Dave Houlton142c4cb2018-10-17 15:04:41 -06003949 skip |=
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003950 LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069",
3951 "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
3952 ") is not 1.",
3953 viewportCount);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003954 }
3955 }
3956
Jeff Bolz9af91c52018-09-01 21:53:57 -05003957 const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003958 if (sum > device_limits.maxViewports) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003959 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067",
3960 "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32
3961 " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
3962 firstViewport, viewportCount, sum, device_limits.maxViewports);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003963 }
3964
3965 return skip;
3966}
3967
Jeff Bolz5c801d12019-10-09 10:38:45 -05003968bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV(
3969 VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount,
3970 const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const {
Jeff Bolz9af91c52018-09-01 21:53:57 -05003971 bool skip = false;
3972
Dave Houlton142c4cb2018-10-17 15:04:41 -06003973 if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003974 skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081",
3975 "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, "
3976 "customSampleOrderCount must be 0.");
Jeff Bolz9af91c52018-09-01 21:53:57 -05003977 }
3978
3979 for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003980 skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]);
Jeff Bolz9af91c52018-09-01 21:53:57 -05003981 }
3982
3983 return skip;
3984}
3985
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07003986bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05003987 uint32_t firstTask) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003988 bool skip = false;
3989
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003990 if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07003991 skip |= LogError(
3992 commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119",
Dave Houlton142c4cb2018-10-17 15:04:41 -06003993 "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32
3994 "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").",
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07003995 taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05003996 }
3997
3998 return skip;
3999}
4000
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004001bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4002 VkDeviceSize offset, uint32_t drawCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004003 uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004004 bool skip = false;
Lockee1c22882019-06-10 16:02:54 -06004005 static const int condition_multiples = 0b0011;
4006 if (offset & condition_multiples) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004007 skip |= LogError(
4008 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710",
Dave Houlton142c4cb2018-10-17 15:04:41 -06004009 "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004010 }
Lockee1c22882019-06-10 16:02:54 -06004011 if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004012 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146",
4013 "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32
4014 "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).",
4015 stride);
Lockee1c22882019-06-10 16:02:54 -06004016 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004017 if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004018 skip |= LogError(
4019 commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718",
4020 "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount);
Jeff Bolzb574c342018-11-08 15:36:57 -06004021 }
4022
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004023 return skip;
4024}
4025
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004026bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer,
4027 VkDeviceSize offset, VkBuffer countBuffer,
4028 VkDeviceSize countBufferOffset,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004029 uint32_t maxDrawCount, uint32_t stride) const {
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004030 bool skip = false;
4031
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004032 if (offset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004033 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710",
4034 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64
4035 "), is not a multiple of 4.",
4036 offset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004037 }
4038
4039 if (countBufferOffset & 3) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004040 skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716",
4041 "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64
4042 "), is not a multiple of 4.",
4043 countBufferOffset);
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004044 }
4045
Jeff Bolz45bf7d62018-09-18 15:39:58 -05004046 return skip;
4047}
4048
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004049bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004050 const VkAllocationCallbacks *pAllocator,
4051 VkQueryPool *pQueryPool) const {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004052 bool skip = false;
4053
4054 // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4055 if (pCreateInfo != nullptr) {
4056 // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of
4057 // VkQueryPipelineStatisticFlagBits values
4058 if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) &&
4059 ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004060 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792",
4061 "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, "
4062 "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits "
4063 "values.");
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004064 }
sfricke-samsung7d69d0d2020-04-25 10:27:27 -07004065 if (pCreateInfo->queryCount == 0) {
4066 skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763",
4067 "vkCreateQueryPool(): queryCount must be greater than zero.");
4068 }
Mark Lobodzinskib7a26382018-07-02 13:14:26 -06004069 }
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004070 return skip;
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004071}
4072
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004073bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice,
4074 const char *pLayerName, uint32_t *pPropertyCount,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004075 VkExtensionProperties *pProperties) const {
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004076 return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties,
4077 true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter");
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004078}
4079
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004080void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004081 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4082 VkResult result) {
4083 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004084 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004085}
4086
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004087void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2KHR *pCreateInfo,
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004088 const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass,
4089 VkResult result) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004090 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskicd05c1e2019-01-17 15:33:46 -07004091 if (result != VK_SUCCESS) return;
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004092 RecordRenderPass(*pRenderPass, pCreateInfo);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004093}
4094
Mark Lobodzinskibf599b92018-12-31 12:15:55 -07004095void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass,
4096 const VkAllocationCallbacks *pAllocator) {
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004097 // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments)
Mark Lobodzinskif27a6bc2019-02-04 13:00:49 -07004098 std::unique_lock<std::mutex> lock(renderpass_map_mutex);
Mark Lobodzinskiaf7c0382018-12-18 11:55:55 -07004099 renderpasses_states.erase(renderPass);
Mark Lobodzinskid4950072017-08-01 13:02:20 -06004100}
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004101
4102bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004103 const VkAllocationCallbacks *pAllocator,
4104 VkDeviceMemory *pMemory) const {
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004105 bool skip = false;
4106
4107 if (pAllocateInfo) {
4108 auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext);
4109 if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004110 skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602",
4111 "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority);
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004112 }
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004113
4114 VkMemoryAllocateFlags flags = 0;
4115 auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext);
4116 if (flags_info) {
4117 flags = flags_info->flags;
4118 }
4119
4120 auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfoKHR>(pAllocateInfo->pNext);
4121 if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) {
4122 if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004123 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329",
4124 "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include "
4125 "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004126 }
4127
4128#ifdef VK_USE_PLATFORM_WIN32_KHR
4129 auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext);
4130#endif
4131 auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext);
4132 auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext);
4133#ifdef VK_USE_PLATFORM_ANDROID_KHR
4134 auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext);
4135#endif
4136
4137 if (import_memory_host_pointer) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004138 skip |= LogError(
4139 device, "VUID-VkMemoryAllocateInfo-pNext-03332",
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004140 "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero.");
4141 }
4142 if (
4143#ifdef VK_USE_PLATFORM_WIN32_KHR
4144 (import_memory_win32_handle && import_memory_win32_handle->handleType) ||
4145#endif
4146 (import_memory_fd && import_memory_fd->handleType) ||
4147#ifdef VK_USE_PLATFORM_ANDROID_KHR
4148 (import_memory_ahb && import_memory_ahb->buffer) ||
4149#endif
4150 (import_memory_host_pointer && import_memory_host_pointer->handleType)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004151 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333",
4152 "If the parameters define an import operation, opaqueCaptureAddress must be zero.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004153 }
4154 }
4155
4156 if (flags) {
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004157 VkBool32 capture_replay = false;
4158 VkBool32 buffer_device_address = false;
4159 const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext);
4160 if (vulkan_12_features) {
4161 capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay;
4162 buffer_device_address = vulkan_12_features->bufferDeviceAddress;
4163 } else {
4164 const auto *bda_features =
4165 lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeaturesKHR>(device_createinfo_pnext);
4166 if (bda_features) {
4167 capture_replay = bda_features->bufferDeviceAddressCaptureReplay;
4168 buffer_device_address = bda_features->bufferDeviceAddress;
4169 }
4170 }
4171 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR) && !capture_replay) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004172 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330",
4173 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR is set, "
4174 "bufferDeviceAddressCaptureReplay must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004175 }
Tony-LunarGa74d3fe2019-11-22 15:43:20 -07004176 if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR) && !buffer_device_address) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004177 skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331",
4178 "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT_KHR is set, bufferDeviceAddress must be enabled.");
Jeff Bolz4563f2a2019-12-10 13:30:30 -06004179 }
4180 }
Jeff Bolz7e7e6e02019-01-11 22:53:41 -06004181 }
4182 return skip;
4183}
Ricardo Garciaa4935972019-02-21 17:43:18 +01004184
Jason Macnak192fa0e2019-07-26 15:07:16 -07004185bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles,
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004186 VkAccelerationStructureNV object_handle, const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004187 bool skip = false;
4188
4189 if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT &&
4190 triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT &&
4191 triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004192 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004193 } else {
4194 uint32_t vertex_component_size = 0;
4195 if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) {
4196 vertex_component_size = 4;
4197 } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM ||
4198 triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) {
4199 vertex_component_size = 2;
4200 }
4201 if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004202 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004203 }
4204 }
4205
4206 if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 &&
4207 triangles.indexType != VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004208 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004209 } else {
4210 uint32_t index_element_size = 0;
4211 if (triangles.indexType == VK_INDEX_TYPE_UINT32) {
4212 index_element_size = 4;
4213 } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) {
4214 index_element_size = 2;
4215 }
4216 if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004217 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004218 }
4219 }
4220 if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) {
4221 if (triangles.indexCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004222 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004223 }
4224 if (triangles.indexData != VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004225 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004226 }
4227 }
4228
4229 if (SafeModulo(triangles.transformOffset, 16) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004230 skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004231 }
4232
4233 return skip;
4234}
4235
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004236bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle,
4237 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004238 bool skip = false;
4239
4240 if (SafeModulo(aabbs.offset, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004241 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004242 }
4243 if (SafeModulo(aabbs.stride, 8) != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004244 skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004245 }
4246
4247 return skip;
4248}
4249
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004250bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle,
4251 const char *func_name) const {
Jason Macnak192fa0e2019-07-26 15:07:16 -07004252 bool skip = false;
4253 if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004254 skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004255 } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004256 skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004257 }
4258 return skip;
4259}
4260
4261bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info,
sourav parmara24fb7b2020-05-26 10:50:04 -07004262 VkAccelerationStructureNV object_handle, const char *func_name,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004263 bool is_cmd) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004264 bool skip = false;
4265 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004266 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425",
4267 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then "
4268 "geometryCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004269 }
4270 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004271 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426",
4272 "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then "
4273 "instanceCount must be 0.");
Jason Macnak5c954952019-07-09 15:46:12 -07004274 }
4275 if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV &&
4276 info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004277 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592",
4278 "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV"
4279 "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 -07004280 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004281 if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004282 skip |= LogError(object_handle,
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06004283 is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241"
4284 : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004285 "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to "
4286 "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004287 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004288 if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004289 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423",
4290 "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to "
4291 "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004292 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004293 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) {
Jason Macnak5c954952019-07-09 15:46:12 -07004294 uint64_t total_triangle_count = 0;
4295 for (uint32_t i = 0; i < info.geometryCount; i++) {
4296 const VkGeometryNV &geometry = info.pGeometries[i];
Jason Macnak192fa0e2019-07-26 15:07:16 -07004297
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004298 skip |= ValidateGeometryNV(geometry, object_handle, func_name);
Jason Macnak192fa0e2019-07-26 15:07:16 -07004299
Jason Macnak5c954952019-07-09 15:46:12 -07004300 if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) {
4301 continue;
4302 }
4303 total_triangle_count += geometry.geometry.triangles.indexCount / 3;
4304 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004305 if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004306 skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424",
4307 "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than "
4308 "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount.");
Jason Macnak5c954952019-07-09 15:46:12 -07004309 }
4310 }
Jason Macnak21ba97e2019-08-09 12:57:44 -07004311 if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) {
4312 const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType;
4313 for (uint32_t i = 1; i < info.geometryCount; i++) {
4314 const VkGeometryNV &geometry = info.pGeometries[i];
4315 if (geometry.geometryType != first_geometry_type) {
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004316 skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004317 "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match "
4318 "info.pGeometries[0].geometryType.",
4319 i);
Jason Macnak21ba97e2019-08-09 12:57:44 -07004320 }
4321 }
4322 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004323 for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) {
4324 if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV ||
4325 info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) {
4326 skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503",
4327 "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV"
4328 "or VK_GEOMETRY_TYPE_AABBS_NV.");
4329 }
4330 }
4331 skip |=
4332 validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV,
Shannon McPherson93970b12020-06-12 14:34:35 -06004333 info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter");
Jason Macnak5c954952019-07-09 15:46:12 -07004334 return skip;
4335}
4336
Ricardo Garciaa4935972019-02-21 17:43:18 +01004337bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV(
4338 VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004339 VkAccelerationStructureNV *pAccelerationStructure) const {
Ricardo Garciaa4935972019-02-21 17:43:18 +01004340 bool skip = false;
Ricardo Garciaa4935972019-02-21 17:43:18 +01004341 if (pCreateInfo) {
4342 if ((pCreateInfo->compactedSize != 0) &&
4343 ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004344 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421",
4345 "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64
4346 ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.",
4347 pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004348 }
Jason Macnak5c954952019-07-09 15:46:12 -07004349
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004350 skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0),
sourav parmara24fb7b2020-05-26 10:50:04 -07004351 "vkCreateAccelerationStructureNV()", false);
Ricardo Garciaa4935972019-02-21 17:43:18 +01004352 }
Ricardo Garciaa4935972019-02-21 17:43:18 +01004353 return skip;
4354}
Mike Schuchardt21638df2019-03-16 10:52:02 -07004355
Jeff Bolz5c801d12019-10-09 10:38:45 -05004356bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer,
4357 const VkAccelerationStructureInfoNV *pInfo,
4358 VkBuffer instanceData, VkDeviceSize instanceOffset,
4359 VkBool32 update, VkAccelerationStructureNV dst,
4360 VkAccelerationStructureNV src, VkBuffer scratch,
4361 VkDeviceSize scratchOffset) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004362 bool skip = false;
4363
4364 if (pInfo != nullptr) {
sourav parmara24fb7b2020-05-26 10:50:04 -07004365 skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true);
Jason Macnak5c954952019-07-09 15:46:12 -07004366 }
4367
4368 return skip;
4369}
4370
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004371bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR(
4372 VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator,
4373 VkAccelerationStructureKHR *pAccelerationStructure) const {
4374 bool skip = false;
4375
4376 if (pCreateInfo) {
4377 for (uint32_t i = 0; i < pCreateInfo->maxGeometryCount; ++i) {
4378 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4379 if (pCreateInfo->pGeometryInfos[i].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4380 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03496",
4381 "VkAccelerationStructureCreateInfoKHR: Top-level acceleration structure "
4382 "pGeometryInfos[%d].geometryType must be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4383 i);
4384 }
4385 }
4386
4387 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && pCreateInfo->compactedSize == 0) {
4388 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) {
4389 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03497",
4390 "VkAccelerationStructureCreateInfoKHR: Bottom-level acceleration structure "
4391 "pGeometryInfos[%d].geometryType must not be VK_GEOMETRY_TYPE_INSTANCES_KHR",
4392 i);
4393 }
4394 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004395 if (pCreateInfo->pGeometryInfos[i].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) {
4396 if (!(pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT16 ||
4397 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_UINT32 ||
4398 pCreateInfo->pGeometryInfos[i].indexType == VK_INDEX_TYPE_NONE_KHR)) {
4399 skip |= LogError(
4400 device, "VUID-VkAccelerationStructureCreateGeometryTypeInfoKHR-geometryType-03502",
4401 "VkAccelerationStructureCreateInfoKHR: If geometryType is VK_GEOMETRY_TYPE_TRIANGLES_KHR, indexType"
4402 "must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR.");
4403 }
4404 }
4405 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR) {
4406 if (pCreateInfo->pGeometryInfos[i].maxPrimitiveCount > phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount) {
4407 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03492",
4408 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4409 "then pGeometryInfos->maxPrimitiveCount %d must be less than or equal to "
4410 "VkPhysicalDeviceRayTracingPropertiesKHR::maxInstanceCount %d.",
4411 pCreateInfo->pGeometryInfos[i].maxPrimitiveCount,
4412 phys_dev_ext_props.ray_tracing_propsKHR.maxInstanceCount);
4413 }
4414 }
4415 }
4416
4417 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pCreateInfo->compactedSize == 0 &&
4418 pCreateInfo->maxGeometryCount != 1) {
4419 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03495",
4420 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR"
4421 "and compactedSize is 0, maxGeometryCount must be 1.");
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004422 }
sourav parmard1521802020-06-07 21:49:02 -07004423 // or VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490
4424 if (pCreateInfo->compactedSize == 0 && pCreateInfo->maxGeometryCount == 0) {
4425 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-02993",
4426 "VkAccelerationStructureCreateInfoKHR: If compactedSize is 0 then maxGeometryCount must not be 0.");
4427 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004428
4429 if (pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR &&
4430 pCreateInfo->flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) {
4431 skip |= LogError(
4432 device, "VUID-VkAccelerationStructureCreateInfoKHR-flags-03499",
4433 "VkAccelerationStructureCreateInfoKHR: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR"
4434 "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.");
4435 }
4436
4437 if (pCreateInfo->compactedSize != 0 && pCreateInfo->maxGeometryCount != 0) {
4438 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-compactedSize-03490",
4439 "VkAccelerationStructureCreateInfoKHR: pCreateInfo->compactedSize nonzero (%" PRIu64
4440 ") with maxGeometryCount (%" PRIu32 ") nonzero.",
4441 pCreateInfo->compactedSize, pCreateInfo->maxGeometryCount);
4442 }
4443
4444 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && pCreateInfo->maxGeometryCount > 1) {
4445 const VkGeometryTypeKHR first_geometry_type = pCreateInfo->pGeometryInfos[0].geometryType;
4446 for (uint32_t i = 1; i < pCreateInfo->maxGeometryCount; i++) {
4447 const VkGeometryTypeKHR geometry_type = pCreateInfo->pGeometryInfos[i].geometryType;
4448 if (geometry_type != first_geometry_type) {
4449 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03498",
4450 "VkAccelerationStructureCreateInfoKHR: pGeometryInfos[%d].geometryType does not match "
4451 "pGeometryInfos[0].geometryType.",
4452 i);
4453 }
4454 }
4455 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004456 if (pCreateInfo->type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR &&
4457 (pCreateInfo->maxGeometryCount > phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount)) {
4458 skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-type-03491",
4459 "VkAccelerationStructureCreateInfoKHR: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR"
4460 "then maxGeometryCount %d must be less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR "
4461 "maxGeometryCount %d.",
4462 pCreateInfo->maxGeometryCount, phys_dev_ext_props.ray_tracing_propsKHR.maxGeometryCount);
4463 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004464 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004465 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4466 if (!raytracing_features || raytracing_features->rayTracingAccelerationStructureCaptureReplay == VK_FALSE) {
4467 if (pCreateInfo->deviceAddress != 0) {
4468 skip |=
4469 LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03500",
4470 "VkAccelerationStructureCreateInfoKHR: If deviceAddress is not 0, "
4471 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingAccelerationStructureCaptureReplay must be VK_TRUE.");
4472 }
4473 }
sourav parmar83c31b12020-05-06 12:30:54 -07004474 if (!raytracing_features || !(raytracing_features->rayQuery == VK_TRUE || raytracing_features->rayTracing == VK_TRUE)) {
4475 skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-rayTracing-03487",
4476 "vkCreateAccelerationStructureKHR: The rayTracing or rayQuery feature must be enabled.");
4477 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004478 return skip;
4479}
4480
Jason Macnak5c954952019-07-09 15:46:12 -07004481bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device,
4482 VkAccelerationStructureNV accelerationStructure,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004483 size_t dataSize, void *pData) const {
Jason Macnak5c954952019-07-09 15:46:12 -07004484 bool skip = false;
4485 if (dataSize < 8) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004486 skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240",
4487 "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8.");
Jason Macnak5c954952019-07-09 15:46:12 -07004488 }
4489 return skip;
4490}
4491
Peter Chen85366392019-05-14 15:20:11 -04004492bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache,
4493 uint32_t createInfoCount,
4494 const VkRayTracingPipelineCreateInfoNV *pCreateInfos,
4495 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004496 VkPipeline *pPipelines) const {
Peter Chen85366392019-05-14 15:20:11 -04004497 bool skip = false;
4498
4499 for (uint32_t i = 0; i < createInfoCount; i++) {
4500 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4501 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
sourav parmar83c31b12020-05-06 12:30:54 -07004502 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969",
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004503 "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32
4504 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4505 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").",
4506 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
Peter Chen85366392019-05-14 15:20:11 -04004507 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004508
4509 const auto *pipeline_cache_contol_features =
4510 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4511 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4512 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4513 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4514 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905",
4515 "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled,"
4516 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4517 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4518 }
4519 }
4520
sourav parmarf4a78252020-04-10 13:04:21 -07004521 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4522 skip |=
4523 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904",
4524 "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4525 }
4526 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) &&
4527 (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) {
4528 skip |=
4529 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957",
4530 "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and"
4531 "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time.");
4532 }
4533 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4534 if (pCreateInfos[i].basePipelineIndex != -1) {
4535 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4536 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423",
4537 "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be "
4538 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4539 "and pCreateInfos->basePipelineIndex is not -1.");
4540 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004541 if (pCreateInfos[i].basePipelineIndex > (int32_t)(i)) {
4542 skip |=
4543 LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415",
4544 "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the"
4545 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element"
4546 "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to "
4547 "that element.");
4548 }
sourav parmarf4a78252020-04-10 13:04:21 -07004549 }
4550 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004551 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004552 skip |=
4553 LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422",
4554 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4555 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling"
4556 "commands pCreateInfos parameter.");
4557 }
4558 } else {
4559 if (pCreateInfos[i].basePipelineIndex != -1) {
4560 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424",
4561 "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4562 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4563 }
4564 }
4565 }
4566 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4567 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456",
4568 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR.");
4569 }
4570 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) {
4571 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458",
4572 "vkCreateRayTracingPipelinesNV: flags must not include "
4573 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR.");
4574 }
4575 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) {
4576 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459",
4577 "vkCreateRayTracingPipelinesNV: flags must not include "
4578 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR.");
4579 }
4580 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) {
4581 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460",
4582 "vkCreateRayTracingPipelinesNV: flags must not include "
4583 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR.");
4584 }
4585 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) {
4586 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461",
4587 "vkCreateRayTracingPipelinesNV: flags must not include "
4588 "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR.");
4589 }
4590 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4591 skip |= LogError(
4592 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462",
4593 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4594 }
4595 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4596 skip |= LogError(
4597 device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463",
4598 "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4599 }
Peter Chen85366392019-05-14 15:20:11 -04004600 }
4601
4602 return skip;
4603}
4604
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004605bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR(VkDevice device, VkPipelineCache pipelineCache,
4606 uint32_t createInfoCount,
4607 const VkRayTracingPipelineCreateInfoKHR *pCreateInfos,
4608 const VkAllocationCallbacks *pAllocator,
4609 VkPipeline *pPipelines) const {
4610 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07004611 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
4612 if (!raytracing_features || raytracing_features->rayTracing == VK_FALSE) {
4613 skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracing-03455",
4614 "vkCreateRayTracingPipelinesKHR(): The rayTracing feature must be enabled.");
4615 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004616 for (uint32_t i = 0; i < createInfoCount; i++) {
4617 auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext);
4618 if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) {
4619 skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670",
4620 "vkCreateRayTracingPipelinesKHR(): in pCreateInfo[%" PRIu32
4621 "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount"
4622 "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").",
4623 i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount);
4624 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004625 const auto *pipeline_cache_contol_features =
4626 lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext);
4627 if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) {
4628 if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT |
4629 VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) {
4630 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905",
4631 "vkCreateRayTracingPipelinesKHR(): If the pipelineCreationCacheControl feature is not enabled,"
4632 "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or"
4633 "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT.");
4634 }
4635 }
sourav parmara96ab1a2020-04-25 16:28:23 -07004636 if (!raytracing_features || raytracing_features->rayTracingPrimitiveCulling == VK_FALSE) {
4637 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) {
4638 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03472",
4639 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4640 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR.");
4641 }
4642 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) {
4643 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPrimitiveCulling-03473",
4644 "vkCreateRayTracingPipelinesKHR(): If the rayTracingPrimitiveCulling feature is not enabled,"
4645 "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR .");
4646 }
4647 }
4648
sourav parmarf4a78252020-04-10 13:04:21 -07004649 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) {
4650 skip |=
4651 LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904",
4652 "vkCreateRayTracingPipelinesKHR(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV.");
4653 }
4654 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) {
4655 if (pCreateInfos[i].pLibraryInterface == NULL)
4656 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465",
4657 "If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, pLibraryInterface must not be NULL.");
4658 }
4659 for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) {
4660 if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) ||
4661 (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) {
4662 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) &&
4663 (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) {
4664 skip |= LogError(
4665 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470",
4666 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR,"
4667 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4668 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element "
4669 "must not be VK_SHADER_UNUSED_KHR");
4670 }
4671 if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) &&
4672 (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) {
4673 skip |= LogError(
4674 device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471",
4675 "If flags includes VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR,"
4676 "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR"
4677 "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that "
4678 "element must not be VK_SHADER_UNUSED_KHR");
4679 }
4680 }
4681 }
4682 if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) {
4683 if (pCreateInfos[i].basePipelineIndex != -1) {
4684 if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) {
4685 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423",
4686 "vkCreateRayTracingPipelinesKHR parameter, pCreateInfos->basePipelineHandle, must be "
4687 "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag "
4688 "and pCreateInfos->basePipelineIndex is not -1.");
4689 }
sourav parmara24fb7b2020-05-26 10:50:04 -07004690 if (pCreateInfos[i].basePipelineIndex > (int32_t)i) {
4691 skip |=
4692 LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415",
4693 "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the"
4694 "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is"
4695 "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that "
4696 "element.");
4697 }
sourav parmarf4a78252020-04-10 13:04:21 -07004698 }
4699 if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) {
David Netod9d7b762020-07-27 15:37:58 -04004700 if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) {
sourav parmarf4a78252020-04-10 13:04:21 -07004701 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422",
4702 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4703 "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling"
4704 "commands pCreateInfos parameter %d.",
4705 pCreateInfos[i].basePipelineIndex, createInfoCount);
4706 }
4707 } else {
4708 if (pCreateInfos[i].basePipelineIndex != -1) {
4709 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424",
4710 "vkCreateRayTracingPipelinesKHR if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and"
4711 "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1.");
4712 }
4713 }
4714 }
4715 if (pCreateInfos[i].libraries.libraryCount == 0) {
4716 if (pCreateInfos[i].stageCount == 0) {
4717 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02958",
4718 "If libraries.libraryCount is zero, then stageCount must not be zero .");
4719 }
4720 if (pCreateInfos[i].groupCount == 0) {
4721 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraries-02959",
4722 "If libraries.libraryCount is zero, then groupCount must not be zero .");
4723 }
4724 } else {
4725 if (pCreateInfos[i].pLibraryInterface == NULL) {
4726 skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-libraryCount-03466",
4727 "If the libraryCount member of libraries is greater than 0, pLibraryInterface must not be NULL.");
4728 }
4729 }
Jeff Bolz443c2ca2020-03-19 12:11:51 -05004730 }
4731
4732 return skip;
4733}
4734
Mike Schuchardt21638df2019-03-16 10:52:02 -07004735#ifdef VK_USE_PLATFORM_WIN32_KHR
4736bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device,
4737 const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004738 VkDeviceGroupPresentModeFlagsKHR *pModes) const {
Mike Schuchardt21638df2019-03-16 10:52:02 -07004739 bool skip = false;
4740 if (!device_extensions.vk_khr_swapchain)
4741 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME);
4742 if (!device_extensions.vk_khr_get_surface_capabilities_2)
4743 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME);
4744 if (!device_extensions.vk_khr_surface)
4745 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME);
4746 if (!device_extensions.vk_khr_get_physical_device_properties_2)
4747 skip |=
4748 OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME);
4749 if (!device_extensions.vk_ext_full_screen_exclusive)
4750 skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME);
4751 skip |= validate_struct_type(
4752 "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR",
4753 pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true,
4754 "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType");
4755 if (pSurfaceInfo != NULL) {
4756 const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = {
4757 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT,
4758 VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT};
4759
4760 skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext",
4761 "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT",
4762 pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR),
4763 allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion,
sfricke-samsung32a27362020-02-28 09:06:42 -08004764 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext",
4765 "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique");
Mike Schuchardt21638df2019-03-16 10:52:02 -07004766
4767 skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface);
4768 }
4769 return skip;
4770}
4771#endif
Tobias Hectorebb855f2019-07-23 12:17:33 +01004772
4773bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo,
4774 const VkAllocationCallbacks *pAllocator,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004775 VkFramebuffer *pFramebuffer) const {
Tobias Hectorebb855f2019-07-23 12:17:33 +01004776 // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml
4777 bool skip = false;
4778 if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT_KHR) == 0) {
4779 skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount,
4780 &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined);
4781 }
4782 return skip;
4783}
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004784
4785bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004786 uint16_t lineStipplePattern) const {
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004787 bool skip = false;
4788
4789 if (lineStippleFactor < 1 || lineStippleFactor > 256) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004790 skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776",
4791 "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor);
Jeff Bolz8125a8b2019-08-16 16:29:45 -05004792 }
4793
4794 return skip;
4795}
Piers Daniell8fd03f52019-08-21 12:07:53 -06004796
4797bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004798 VkDeviceSize offset, VkIndexType indexType) const {
Piers Daniell8fd03f52019-08-21 12:07:53 -06004799 bool skip = false;
4800
4801 if (indexType == VK_INDEX_TYPE_NONE_NV) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004802 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507",
4803 "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004804 }
4805
Tony-LunarG6c3c5452019-12-13 10:37:38 -07004806 const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext);
Mark Lobodzinski804fde82020-05-08 07:49:25 -06004807 if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004808 skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765",
4809 "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled.");
Piers Daniell8fd03f52019-08-21 12:07:53 -06004810 }
4811
4812 return skip;
4813}
Mark Lobodzinski84988402019-09-11 15:27:30 -06004814
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004815bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding,
4816 uint32_t bindingCount, const VkBuffer *pBuffers,
4817 const VkDeviceSize *pOffsets) const {
4818 bool skip = false;
4819 if (firstBinding > device_limits.maxVertexInputBindings) {
4820 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624",
4821 "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding,
4822 device_limits.maxVertexInputBindings);
4823 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
4824 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625",
4825 "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than "
4826 "maxVertexInputBindings (%u)",
4827 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
4828 }
4829
Jeff Bolz165818a2020-05-08 11:19:03 -05004830 for (uint32_t i = 0; i < bindingCount; ++i) {
4831 if (pBuffers[i] == VK_NULL_HANDLE) {
4832 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
4833 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
4834 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001",
4835 "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
4836 } else {
4837 if (pOffsets[i] != 0) {
4838 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002",
4839 "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
4840 }
4841 }
4842 }
4843 }
4844
sfricke-samsung4ada8d42020-02-09 17:43:11 -08004845 return skip;
4846}
4847
Mark Lobodzinski84988402019-09-11 15:27:30 -06004848bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004849 const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004850 bool skip = false;
4851 if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004852 skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589",
4853 "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004854 }
4855 return skip;
4856}
4857
4858bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device,
Jeff Bolz5c801d12019-10-09 10:38:45 -05004859 const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const {
Mark Lobodzinski84988402019-09-11 15:27:30 -06004860 bool skip = false;
4861 if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004862 skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908",
4863 "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN.");
Mark Lobodzinski84988402019-09-11 15:27:30 -06004864 }
4865 return skip;
4866}
Petr Kraus3d720392019-11-13 02:52:39 +01004867
4868bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout,
4869 VkSemaphore semaphore, VkFence fence,
4870 uint32_t *pImageIndex) const {
4871 bool skip = false;
4872
4873 if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004874 skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780",
4875 "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004876 }
4877
4878 return skip;
4879}
4880
4881bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo,
4882 uint32_t *pImageIndex) const {
4883 bool skip = false;
4884
4885 if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07004886 skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782",
4887 "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE.");
Petr Kraus3d720392019-11-13 02:52:39 +01004888 }
4889
4890 return skip;
4891}
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004892
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06004893bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer,
4894 uint32_t firstBinding, uint32_t bindingCount,
4895 const VkBuffer *pBuffers,
4896 const VkDeviceSize *pOffsets,
4897 const VkDeviceSize *pSizes) const {
4898 bool skip = false;
4899
4900 char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT";
4901 for (uint32_t i = 0; i < bindingCount; ++i) {
4902 if (pOffsets[i] & 3) {
4903 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359",
4904 "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]);
4905 }
4906 }
4907
4908 if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4909 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356",
4910 "%s: The firstBinding(%" PRIu32
4911 ") index is greater than or equal to "
4912 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4913 cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4914 }
4915
4916 if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4917 skip |=
4918 LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357",
4919 "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32
4920 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4921 cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4922 }
4923
4924 for (uint32_t i = 0; i < bindingCount; ++i) {
4925 // pSizes is optional and may be nullptr.
4926 if (pSizes != nullptr) {
4927 if (pSizes[i] != VK_WHOLE_SIZE &&
4928 pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) {
4929 skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361",
4930 "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64
4931 ") is not VK_WHOLE_SIZE and is greater than "
4932 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.",
4933 cmd_name, i, pSizes[i]);
4934 }
4935 }
4936 }
4937
4938 return skip;
4939}
4940
4941bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4942 uint32_t firstCounterBuffer,
4943 uint32_t counterBufferCount,
4944 const VkBuffer *pCounterBuffers,
4945 const VkDeviceSize *pCounterBufferOffsets) const {
4946 bool skip = false;
4947
4948 char const *const cmd_name = "CmdBeginTransformFeedbackEXT";
4949 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4950 skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368",
4951 "%s: The firstCounterBuffer(%" PRIu32
4952 ") index is greater than or equal to "
4953 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4954 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4955 }
4956
4957 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4958 skip |=
4959 LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369",
4960 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4961 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4962 cmd_name, firstCounterBuffer, counterBufferCount,
4963 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4964 }
4965
4966 return skip;
4967}
4968
4969bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer,
4970 uint32_t firstCounterBuffer, uint32_t counterBufferCount,
4971 const VkBuffer *pCounterBuffers,
4972 const VkDeviceSize *pCounterBufferOffsets) const {
4973 bool skip = false;
4974
4975 char const *const cmd_name = "CmdEndTransformFeedbackEXT";
4976 if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4977 skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376",
4978 "%s: The firstCounterBuffer(%" PRIu32
4979 ") index is greater than or equal to "
4980 "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4981 cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4982 }
4983
4984 if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) {
4985 skip |=
4986 LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377",
4987 "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32
4988 ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").",
4989 cmd_name, firstCounterBuffer, counterBufferCount,
4990 phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers);
4991 }
4992
4993 return skip;
4994}
4995
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07004996bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount,
4997 uint32_t firstInstance, VkBuffer counterBuffer,
4998 VkDeviceSize counterBufferOffset,
4999 uint32_t counterOffset, uint32_t vertexStride) const {
5000 bool skip = false;
5001
5002 if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005003 skip |= LogError(
5004 counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289",
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005005 "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).",
5006 vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride);
5007 }
5008
sfricke-samsungd5e9adb2020-10-26 03:59:29 -07005009 if ((counterOffset % 4) != 0) {
5010 // TODO - Update when header are updated
5011 skip |= LogError(commandBuffer, "UNASSIGNED-vkCmdDrawIndirectByteCountEXT-offset",
5012 "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset);
5013 }
5014
Mark Lobodzinski953b7bc2019-12-19 13:50:10 -07005015 return skip;
5016}
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005017
5018bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device,
5019 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5020 const VkAllocationCallbacks *pAllocator,
5021 VkSamplerYcbcrConversion *pYcbcrConversion,
5022 const char *apiName) const {
5023 bool skip = false;
5024
5025 // Check samplerYcbcrConversion feature is set
Tony-LunarG6c3c5452019-12-13 10:37:38 -07005026 const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext);
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005027 if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) {
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005028 const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext);
5029 if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) {
5030 skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648",
sfricke-samsung83d98122020-07-04 06:21:15 -07005031 "%s: samplerYcbcrConversion must be enabled.", apiName);
Ricardo Garcia3a34ffb2020-06-24 09:36:18 +02005032 }
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005033 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005034
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005035#ifdef VK_USE_PLATFORM_ANDROID_KHR
5036 const VkExternalFormatANDROID *pExternalFormatANDROID = lvl_find_in_chain<VkExternalFormatANDROID>(pCreateInfo);
5037 const bool isExternalFormat = pExternalFormatANDROID != nullptr && pExternalFormatANDROID->externalFormat != 0;
5038#else
5039 const bool isExternalFormat = false;
5040#endif
5041
sfricke-samsung1a72f942020-07-25 12:09:18 -07005042 const VkFormat format = pCreateInfo->format;
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005043
5044 // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored.
5045 if (!isExternalFormat) {
5046 const VkComponentMapping components = pCreateInfo->components;
5047 // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec
5048 if (FormatIsXChromaSubsampled(format) == true) {
5049 if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) {
5050 skip |=
5051 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581",
sfricke-samsung83d98122020-07-04 06:21:15 -07005052 "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G "
5053 "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005054 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005055 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005056
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005057 if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5058 (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) {
5059 skip |= LogError(
5060 device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582",
5061 "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or "
5062 "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.",
5063 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a));
5064 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005065
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005066 if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5067 (components.r != VK_COMPONENT_SWIZZLE_B)) {
5068 skip |=
5069 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583",
sfricke-samsung83d98122020-07-04 06:21:15 -07005070 "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R "
5071 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005072 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005073 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005074
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005075 if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) &&
5076 (components.b != VK_COMPONENT_SWIZZLE_R)) {
5077 skip |=
5078 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584",
sfricke-samsung83d98122020-07-04 06:21:15 -07005079 "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B "
5080 "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005081 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005082 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005083
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005084 // If one is identity, both need to be
5085 const bool rIdentity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY));
5086 const bool bIdentity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY));
5087 if ((rIdentity != bIdentity) && ((rIdentity == true) || (bIdentity == true))) {
5088 skip |=
5089 LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585",
sfricke-samsung83d98122020-07-04 06:21:15 -07005090 "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) "
5091 "are an identity swizzle, then both need to be an identity swizzle.",
sfricke-samsung1a72f942020-07-25 12:09:18 -07005092 apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r),
5093 string_VkComponentSwizzle(components.b));
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005094 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005095 }
5096
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005097 if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) {
5098 // Checks same VU multiple ways in order to give a more useful error message
5099 const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655";
5100 if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) ||
5101 (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) ||
5102 (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) {
5103 skip |= LogError(
5104 device, vuid,
5105 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5106 "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.",
5107 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5108 string_VkComponentSwizzle(components.b));
5109 }
sfricke-samsung1a72f942020-07-25 12:09:18 -07005110
Benjamin Thautd0bc2a92020-08-25 17:09:09 +02005111 // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA"
5112 // 4 channel format = no issue
5113 // 3 = no [a]
5114 // 2 = no [b,a]
5115 // 1 = no [g,b,a]
5116 // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it)
5117 const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format);
5118
5119 if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) ||
5120 (components.b == VK_COMPONENT_SWIZZLE_A))) {
5121 skip |= LogError(device, vuid,
5122 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5123 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.",
5124 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5125 string_VkComponentSwizzle(components.b));
5126 } else if ((channels < 3) &&
5127 ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) ||
5128 (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) {
5129 skip |= LogError(device, vuid,
5130 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5131 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B "
5132 "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5133 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5134 string_VkComponentSwizzle(components.b));
5135 } else if ((channels < 2) &&
5136 ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) ||
5137 (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) {
5138 skip |= LogError(device, vuid,
5139 "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), "
5140 "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G "
5141 "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).",
5142 apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g),
5143 string_VkComponentSwizzle(components.b));
5144 }
sfricke-samsung83d98122020-07-04 06:21:15 -07005145 }
5146 }
5147
sfricke-samsung11ea8ed2020-01-07 22:24:56 -08005148 return skip;
5149}
5150
5151bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device,
5152 const VkSamplerYcbcrConversionCreateInfo *pCreateInfo,
5153 const VkAllocationCallbacks *pAllocator,
5154 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5155 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5156 "vkCreateSamplerYcbcrConversion");
5157}
5158
5159bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR(
5160 VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator,
5161 VkSamplerYcbcrConversion *pYcbcrConversion) const {
5162 return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion,
5163 "vkCreateSamplerYcbcrConversionKHR");
5164}
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005165
5166bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR(
5167 VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const {
5168 bool skip = false;
5169 VkExternalSemaphoreHandleTypeFlags supported_handle_types =
5170 VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT;
5171
5172 if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) {
Mark Lobodzinski5d8244a2020-01-23 13:00:43 -07005173 skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143",
5174 "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).",
5175 report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(),
5176 string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType),
5177 string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str());
sfricke-samsung1708a8c2020-02-10 00:35:06 -08005178 }
5179 return skip;
5180}
sourav parmara96ab1a2020-04-25 16:28:23 -07005181
5182bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR(
5183 VkDevice device, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5184 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005185 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5186 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5187 skip |=
5188 LogError(device, "", "VUID-vkCopyAccelerationStructureToMemoryKHR-rayTracingHostAccelerationStructureCommands-03447",
5189 "vkCopyAccelerationStructureToMemoryKHR: the "
5190 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5191 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005192 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5193 skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5194 "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5195 }
5196 return skip;
5197}
5198
5199bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR(
5200 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const {
5201 bool skip = false;
5202 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) {
5203 skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update
5204 LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412",
5205 "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR.");
5206 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005207 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5208 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005209 skip |= LogError(
5210 commandBuffer, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pNext-03560",
5211 "vkCmdCopyAccelerationStructureToMemoryKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5212 "pNext chain of the VkCopyAccelerationStructureToMemoryInfoKHR structure.");
5213 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005214 return skip;
5215}
5216
5217bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo,
5218 const char *api_name) const {
5219 bool skip = false;
5220 if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR ||
5221 pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) {
5222 skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410",
5223 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR"
5224 "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.",
5225 api_name);
5226 }
5227 return skip;
5228}
5229
5230bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR(
5231 VkDevice device, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5232 bool skip = false;
5233 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()");
sourav parmar83c31b12020-05-06 12:30:54 -07005234 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5235 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5236 skip |= LogError(
5237 device, "VUID-vkCopyAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03441",
5238 "vkCopyAccelerationStructureKHR(): the "
5239 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled .");
5240 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005241 return skip;
5242}
5243
5244bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR(
5245 VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const {
5246 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005247 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5248 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005249 skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureKHR-pNext-03557",
5250 "vkCmdCopyAccelerationStructureKHR(): The VkDeferredOperationInfoKHR structure must not be included in "
5251 "the pNext chain of the VkCopyAccelerationStructureInfoKHR structure.");
5252 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005253 skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()");
5254 return skip;
5255}
5256
5257bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005258 const char *api_name, bool is_cmd) const {
sourav parmara96ab1a2020-04-25 16:28:23 -07005259 bool skip = false;
5260 if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) {
sourav parmar83c31b12020-05-06 12:30:54 -07005261 skip |= LogError(device,
Mark Lobodzinskiaad69e42020-05-12 08:44:21 -06005262 is_cmd ? "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-mode-03413"
Shannon McPhersonafe55122020-05-25 16:20:19 -06005263 : "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413",
sourav parmara96ab1a2020-04-25 16:28:23 -07005264 "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name);
5265 }
5266 return skip;
5267}
5268
5269bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR(
5270 VkDevice device, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5271 bool skip = false;
sourav parmar83c31b12020-05-06 12:30:54 -07005272 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true);
5273 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5274 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5275 skip |=
5276 LogError(device, "VUID-vkCopyMemoryToAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03444",
5277 "vkCopyMemoryToAccelerationStructureKHR() :the "
5278 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands feature must be enabled.");
5279 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005280 return skip;
5281}
Jeremy Hayes9bda85a2020-05-21 16:36:17 -06005282
sourav parmara96ab1a2020-04-25 16:28:23 -07005283bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR(
5284 VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const {
5285 bool skip = false;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005286 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5287 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005288 skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pNext-03564",
5289 "vkCmdCopyMemoryToAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must"
5290 "not be included in the pNext chain of the VkCopyMemoryToAccelerationStructureInfoKHR structure.");
5291 }
sourav parmar83c31b12020-05-06 12:30:54 -07005292 skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false);
5293 return skip;
5294}
5295bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR(
5296 VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5297 VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const {
5298 bool skip = false;
5299 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5300 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5301 skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5302 "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be "
5303 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5304 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5305 }
5306 return skip;
5307}
5308bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR(
5309 VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures,
5310 VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const {
5311 bool skip = false;
5312 if (dataSize < accelerationStructureCount * stride) {
5313 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452",
5314 "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to "
5315 "accelerationStructureCount (%d) *stride(%zu).",
5316 dataSize, accelerationStructureCount, stride);
5317 }
5318 if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR ||
5319 queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) {
5320 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432",
5321 "vkWriteAccelerationStructuresPropertiesKHR: queryType must be "
5322 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or "
5323 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR.");
5324 }
5325 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) {
5326 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5327 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448",
5328 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5329 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR,"
5330 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5331 stride);
5332 }
5333 }
5334 if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) {
5335 if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) {
5336 skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450",
5337 "vkWriteAccelerationStructuresPropertiesKHR: If queryType is "
5338 "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR,"
5339 "then stride (%zu) must be a multiple of the size of VkDeviceSize",
5340 stride);
5341 }
5342 }
5343 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5344 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
5345 skip |=
5346 LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-rayTracingHostAccelerationStructureCommands-03454",
5347 "vkWriteAccelerationStructuresPropertiesKHR: the "
5348 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5349 "feature must be enabled ");
5350 }
5351 return skip;
5352}
5353bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR(
5354 VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const {
5355 bool skip = false;
5356 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5357 if (!raytracing_features || raytracing_features->rayTracingShaderGroupHandleCaptureReplay == VK_FALSE) {
5358 skip |= LogError(device,
5359 "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingShaderGroupHandleCaptureReplay-03485",
5360 "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR: "
5361 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingShaderGroupHandleCaptureReplay"
5362 "must be enabled to call this function.");
5363 }
5364 return skip;
5365}
5366
5367bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer,
5368 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5369 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5370 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5371 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5372 uint32_t width, uint32_t height, uint32_t depth) const {
5373 bool skip = false;
5374 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5375 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04038",
5376 "vkCmdTraceRaysKHR: The offset member of pCallableShaderBindingTable"
5377 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5378 }
5379 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5380 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04040",
5381 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5382 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5383 }
5384 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5385 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041",
5386 "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be"
5387 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5388 }
5389 // hitShader
5390 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5391 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04032",
5392 "vkCmdTraceRaysKHR: The offset member of pHitShaderBindingTable must be a multiple"
5393 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5394 }
5395 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5396 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04034",
5397 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple"
5398 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5399 }
5400 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5401 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035",
5402 "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be"
5403 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5404 }
5405
5406 // missShader
5407 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5408 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-offset-04026",
5409 "vkCmdTraceRaysKHR: The offset member of pMissShaderBindingTable must be a multiple"
5410 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5411 }
5412 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5413 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04028",
5414 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple"
5415 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5416 }
5417 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5418 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029",
5419 "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be"
5420 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5421 }
5422
5423 // raygenShader
5424 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5425 skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-04021",
5426 "vkCmdTraceRaysKHR: pRayGenShaderBindingTable->offset must be a multiple"
5427 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5428 }
5429 return skip;
5430}
5431
5432bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR(VkCommandBuffer commandBuffer,
5433 const VkStridedBufferRegionKHR *pRaygenShaderBindingTable,
5434 const VkStridedBufferRegionKHR *pMissShaderBindingTable,
5435 const VkStridedBufferRegionKHR *pHitShaderBindingTable,
5436 const VkStridedBufferRegionKHR *pCallableShaderBindingTable,
5437 VkBuffer buffer, VkDeviceSize offset) const {
5438 bool skip = false;
5439 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5440 if (!raytracing_features || raytracing_features->rayTracingIndirectTraceRays == VK_FALSE) {
5441 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingIndirectTraceRays-03518",
5442 "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectTraceRays "
5443 "feature must be enabled.");
5444 }
5445 if (SafeModulo(pCallableShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5446 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04038",
5447 "vkCmdTraceRaysIndirectKHR: The offset member of pCallableShaderBindingTable"
5448 "must be a multiple of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5449 }
5450 if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5451 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04040",
5452 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple"
5453 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5454 }
5455 if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5456 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041",
5457 "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be"
5458 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5459 }
5460 // hitShader
5461 if (SafeModulo(pHitShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5462 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04032",
5463 "vkCmdTraceRaysIndirectKHR: The offset member of pHitShaderBindingTable must be a multiple"
5464 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5465 }
5466 if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5467 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04034",
5468 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple"
5469 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5470 }
5471 if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5472 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035",
5473 "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be"
5474 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5475 }
5476
5477 // missShader
5478 if (SafeModulo(pMissShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5479 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-offset-04026",
5480 "vkCmdTraceRaysIndirectKHR: The offset member of pMissShaderBindingTable must be a multiple"
5481 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5482 }
5483 if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleSize) != 0) {
5484 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04028",
5485 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be a multiple"
5486 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupHandleSize.");
5487 }
5488 if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) {
5489 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029",
5490 "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be"
5491 "less than or equal to VkPhysicalDeviceRayTracingPropertiesKHR::maxShaderGroupStride.");
5492 }
5493
5494 // raygenShader
5495 if (SafeModulo(pRaygenShaderBindingTable->offset, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) {
5496 skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-04021",
5497 "vkCmdTraceRaysIndirectKHR: pRayGenShaderBindingTable->offset must be a multiple"
5498 "of VkPhysicalDeviceRayTracingPropertiesKHR::shaderGroupBaseAlignment.");
5499 }
5500 return skip;
5501}
5502bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV(
5503 VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset,
5504 VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride,
5505 VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride,
5506 VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride,
5507 uint32_t width, uint32_t height, uint32_t depth) const {
5508 bool skip = false;
5509 if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5510 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462",
5511 "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of "
5512 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5513 }
5514 if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5515 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465",
5516 "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of "
5517 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5518 }
5519 if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5520 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468",
5521 "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to "
5522 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. ");
5523 }
5524
5525 // hitShader
5526 if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5527 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460",
5528 "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of "
5529 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5530 }
5531 if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5532 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464",
5533 "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of "
5534 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5535 }
5536 if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5537 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467",
5538 "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to "
5539 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5540 }
5541
5542 // missShader
5543 if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5544 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458",
5545 "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of "
5546 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5547 }
5548 if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) {
5549 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463",
5550 "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of "
5551 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize.");
5552 }
5553 if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) {
5554 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466",
5555 "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to "
5556 "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride.");
5557 }
5558
5559 // raygenShader
5560 if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) {
5561 skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456",
5562 "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of "
sourav parmard1521802020-06-07 21:49:02 -07005563 "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment.");
5564 }
5565 if (width > device_limits.maxComputeWorkGroupCount[0]) {
5566 skip |=
5567 LogError(device, "VUID-vkCmdTraceRaysNV-width-02469",
5568 "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o].");
5569 }
5570 if (height > device_limits.maxComputeWorkGroupCount[1]) {
5571 skip |=
5572 LogError(device, "VUID-vkCmdTraceRaysNV-height-02470",
5573 "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1].");
5574 }
5575 if (depth > device_limits.maxComputeWorkGroupCount[2]) {
5576 skip |=
5577 LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471",
5578 "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2].");
sourav parmar83c31b12020-05-06 12:30:54 -07005579 }
5580 return skip;
5581}
5582
5583bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureIndirectKHR(
5584 VkCommandBuffer commandBuffer, const VkAccelerationStructureBuildGeometryInfoKHR *pInfo, VkBuffer indirectBuffer,
5585 VkDeviceSize indirectOffset, uint32_t indirectStride) const {
5586 bool skip = false;
5587 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5588 if (!raytracing_features || raytracing_features->rayTracingIndirectAccelerationStructureBuild == VK_FALSE) {
5589 skip |= LogError(
5590 device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-rayTracingIndirectAccelerationStructureBuild-03535",
5591 "vkCmdBuildAccelerationStructureIndirectKHR: The "
5592 "VkPhysicalDeviceRayTracingFeaturesKHR::rayTracingIndirectAccelerationStructureBuild feature must be enabled.");
5593 }
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005594 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfo->pNext);
5595 if (pnext_struct) {
sourav parmar83c31b12020-05-06 12:30:54 -07005596 skip |=
5597 LogError(device, "VUID-vkCmdBuildAccelerationStructureIndirectKHR-pNext-03536",
5598 "vkCmdBuildAccelerationStructureIndirectKHR: The VkDeferredOperationInfoKHR structure must not be included in "
5599 "the pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5600 }
5601 return false;
5602}
5603
5604bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR(
5605 VkDevice device, const VkAccelerationStructureVersionKHR *version) const {
5606 bool skip = false;
5607 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5608 if (!raytracing_features || !(raytracing_features->rayQuery || raytracing_features->rayTracing)) {
5609 skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracing-03565",
5610 "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled.");
5611 }
5612 return skip;
5613}
5614
5615bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructureKHR(
5616 VkDevice device, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5617 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5618 bool skip = false;
5619 const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingFeaturesKHR>(device_createinfo_pnext);
5620 if (!raytracing_features || raytracing_features->rayTracingHostAccelerationStructureCommands == VK_FALSE) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005621 skip |= LogError(device, "VUID-vkBuildAccelerationStructureKHR-rayTracingHostAccelerationStructureCommands-03439",
5622 "vkBuildAccelerationStructureKHR: The "
5623 "vkPhysicalDeviceRayTracingFeaturesKHR::rayTracingHostAccelerationStructureCommands"
5624 "feature must be enabled .");
sourav parmar83c31b12020-05-06 12:30:54 -07005625 }
sourav parmara96ab1a2020-04-25 16:28:23 -07005626 return skip;
5627}
sourav parmara24fb7b2020-05-26 10:50:04 -07005628bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureKHR(
5629 VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos,
5630 const VkAccelerationStructureBuildOffsetInfoKHR *const *ppOffsetInfos) const {
5631 bool skip = false;
5632 for (uint32_t i = 0; i < infoCount; ++i) {
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005633 const auto *pnext_struct = lvl_find_in_chain<VkDeferredOperationInfoKHR>(pInfos->pNext);
5634 if (pnext_struct) {
sourav parmara24fb7b2020-05-26 10:50:04 -07005635 skip |=
5636 LogError(commandBuffer, "VUID-vkCmdBuildAccelerationStructureKHR-pNext-03532",
5637 "vkCmdBuildAccelerationStructureKHR: The VkDeferredOperationInfoKHR structure must not be included in the"
5638 "pNext chain of any of the provided VkAccelerationStructureBuildGeometryInfoKHR structures.");
5639 }
5640 }
5641 return skip;
Mark Lobodzinski17dc4602020-05-29 07:48:40 -06005642}
Piers Daniell39842ee2020-07-10 16:42:33 -06005643
5644bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount,
5645 const VkViewport *pViewports) const {
5646 bool skip = false;
5647
5648 if (!physical_device_features.multiViewport) {
5649 if (viewportCount != 1) {
5650 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395",
5651 "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32
5652 ") is not 1.",
5653 viewportCount);
5654 }
5655 } else { // multiViewport enabled
5656 if (viewportCount < 1 || viewportCount > device_limits.maxViewports) {
5657 skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394",
5658 "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32
5659 ") must "
5660 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5661 viewportCount, device_limits.maxViewports);
5662 }
5663 }
5664
5665 if (pViewports) {
5666 for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) {
5667 const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr
5668 const char *fn_name = "vkCmdSetViewportWithCountEXT";
5669 skip |= manual_PreCallValidateViewport(
5670 viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer);
5671 }
5672 }
5673
5674 return skip;
5675}
5676
5677bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount,
5678 const VkRect2D *pScissors) const {
5679 bool skip = false;
5680
5681 if (!physical_device_features.multiViewport) {
5682 if (scissorCount != 1) {
5683 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398",
5684 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5685 ") must "
5686 "be 1 when the multiViewport feature is disabled.",
5687 scissorCount);
5688 }
5689 } else { // multiViewport enabled
5690 if (scissorCount == 0) {
5691 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5692 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5693 ") must "
5694 "be great than zero.",
5695 scissorCount);
5696 } else if (scissorCount > device_limits.maxViewports) {
5697 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397",
5698 "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32
5699 ") must "
5700 "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").",
5701 scissorCount, device_limits.maxViewports);
5702 }
5703 }
5704
5705 if (pScissors) {
5706 for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) {
5707 const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr
5708
5709 if (scissor.offset.x < 0) {
5710 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5711 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i,
5712 scissor.offset.x);
5713 }
5714
5715 if (scissor.offset.y < 0) {
5716 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399",
5717 "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i,
5718 scissor.offset.y);
5719 }
5720
5721 const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width);
5722 if (x_sum > INT32_MAX) {
5723 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400",
5724 "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5725 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5726 scissor.offset.x, scissor.extent.width, x_sum, scissor_i);
5727 }
5728
5729 const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height);
5730 if (y_sum > INT32_MAX) {
5731 skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401",
5732 "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64
5733 ") of pScissors[%" PRIu32 "] will overflow int32_t.",
5734 scissor.offset.y, scissor.extent.height, y_sum, scissor_i);
5735 }
5736 }
5737 }
5738
5739 return skip;
5740}
5741
5742bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding,
5743 uint32_t bindingCount, const VkBuffer *pBuffers,
5744 const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes,
5745 const VkDeviceSize *pStrides) const {
5746 bool skip = false;
5747 if (firstBinding >= device_limits.maxVertexInputBindings) {
5748 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355",
5749 "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)",
5750 firstBinding, device_limits.maxVertexInputBindings);
5751 } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) {
5752 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356",
5753 "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than "
5754 "maxVertexInputBindings (%u)",
5755 firstBinding, bindingCount, device_limits.maxVertexInputBindings);
5756 }
5757
5758 for (uint32_t i = 0; i < bindingCount; ++i) {
5759 if (pBuffers[i] == VK_NULL_HANDLE) {
5760 const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext);
5761 if (!(robustness2_features && robustness2_features->nullDescriptor)) {
5762 skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111",
5763 "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i);
5764 } else {
5765 if (pOffsets[i] != 0) {
5766 skip |=
5767 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112",
5768 "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i);
5769 }
5770 }
5771 }
5772 if (pStrides) {
5773 if (pStrides[i] > device_limits.maxVertexInputBindingStride) {
5774 skip |=
5775 LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362",
5776 "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i,
5777 pStrides[i], device_limits.maxVertexInputBindingStride);
5778 }
5779 }
5780 }
5781
5782 return skip;
5783}