sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 1 | /* 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 Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 5 | * |
| 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 Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 19 | * Author: John Zulauf <jzulauf@lunarg.com> |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 20 | */ |
| 21 | |
orbea | 80ddc06 | 2019-09-10 10:33:19 -0700 | [diff] [blame] | 22 | #include <cmath> |
Shahbaz Youssefi | 6be1141 | 2019-01-10 15:29:30 -0500 | [diff] [blame] | 23 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 24 | #include "chassis.h" |
| 25 | #include "stateless_validation.h" |
Mark Lobodzinski | e514d1a | 2019-03-12 08:47:45 -0600 | [diff] [blame] | 26 | #include "layer_chassis_dispatch.h" |
Tobias Hector | d942eb9 | 2018-10-22 15:18:56 +0100 | [diff] [blame] | 27 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 28 | static const int kMaxParamCheckerStringLength = 256; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 29 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 30 | template <typename T> |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 31 | inline bool in_inclusive_range(const T &value, const T &min, const T &max) { |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 32 | // Using only < for generality and || for early abort |
| 33 | return !((value < min) || (max < value)); |
| 34 | } |
| 35 | |
Mark Lobodzinski | 21b91fe | 2020-12-03 15:44:24 -0700 | [diff] [blame] | 36 | read_lock_guard_t StatelessValidation::read_lock() { return read_lock_guard_t(validation_object_mutex, std::defer_lock); } |
| 37 | write_lock_guard_t StatelessValidation::write_lock() { return write_lock_guard_t(validation_object_mutex, std::defer_lock); } |
| 38 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame^] | 39 | static std::unordered_map<VkCommandBuffer, VkCommandPool> secondary_cb_map{}; |
| 40 | static ReadWriteLock secondary_cb_map_mutex; |
| 41 | static read_lock_guard_t cb_read_lock() { |
| 42 | return read_lock_guard_t(secondary_cb_map_mutex); |
| 43 | } |
| 44 | static write_lock_guard_t cb_write_lock() { |
| 45 | return write_lock_guard_t(secondary_cb_map_mutex); |
| 46 | } |
| 47 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 48 | bool StatelessValidation::validate_string(const char *apiName, const ParameterName &stringName, const std::string &vuid, |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 49 | const char *validateString) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 50 | bool skip = false; |
| 51 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 52 | VkStringErrorFlags result = vk_string_validate(kMaxParamCheckerStringLength, validateString); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 53 | |
| 54 | if (result == VK_STRING_ERROR_NONE) { |
| 55 | return skip; |
| 56 | } else if (result & VK_STRING_ERROR_LENGTH) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 57 | skip = LogError(device, vuid, "%s: string %s exceeds max length %d", apiName, stringName.get_name().c_str(), |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 58 | kMaxParamCheckerStringLength); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 59 | } else if (result & VK_STRING_ERROR_BAD_DATA) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 60 | skip = LogError(device, vuid, "%s: string %s contains invalid characters or is badly formed", apiName, |
| 61 | stringName.get_name().c_str()); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 62 | } |
| 63 | return skip; |
| 64 | } |
| 65 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 66 | bool StatelessValidation::validate_api_version(uint32_t api_version, uint32_t effective_api_version) const { |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 67 | bool skip = false; |
| 68 | uint32_t api_version_nopatch = VK_MAKE_VERSION(VK_VERSION_MAJOR(api_version), VK_VERSION_MINOR(api_version), 0); |
| 69 | if (api_version_nopatch != effective_api_version) { |
sfricke-samsung | 6aec21b | 2020-11-01 07:49:43 -0800 | [diff] [blame] | 70 | if ((api_version_nopatch < VK_API_VERSION_1_0) && (api_version != 0)) { |
| 71 | skip |= LogError(instance, "VUID-VkApplicationInfo-apiVersion-04010", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 72 | "Invalid CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " |
| 73 | "Using VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", |
| 74 | api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version)); |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 75 | } else { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 76 | skip |= LogWarning(instance, kVUIDUndefined, |
| 77 | "Unrecognized CreateInstance->pCreateInfo->pApplicationInfo.apiVersion number (0x%08x). " |
| 78 | "Assuming VK_API_VERSION_%" PRIu32 "_%" PRIu32 ".", |
| 79 | api_version, VK_VERSION_MAJOR(effective_api_version), VK_VERSION_MINOR(effective_api_version)); |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 80 | } |
| 81 | } |
| 82 | return skip; |
| 83 | } |
| 84 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 85 | bool StatelessValidation::validate_instance_extensions(const VkInstanceCreateInfo *pCreateInfo) const { |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 86 | bool skip = false; |
Mark Lobodzinski | 05cce20 | 2019-08-27 10:28:37 -0600 | [diff] [blame] | 87 | // Create and use a local instance extension object, as an actual instance has not been created yet |
| 88 | uint32_t specified_version = (pCreateInfo->pApplicationInfo ? pCreateInfo->pApplicationInfo->apiVersion : VK_API_VERSION_1_0); |
| 89 | InstanceExtensions local_instance_extensions; |
| 90 | local_instance_extensions.InitFromInstanceCreateInfo(specified_version, pCreateInfo); |
| 91 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 92 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
Mark Lobodzinski | 05cce20 | 2019-08-27 10:28:37 -0600 | [diff] [blame] | 93 | skip |= validate_extension_reqs(local_instance_extensions, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388", |
| 94 | "instance", pCreateInfo->ppEnabledExtensionNames[i]); |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 95 | } |
| 96 | |
| 97 | return skip; |
| 98 | } |
| 99 | |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 100 | bool StatelessValidation::SupportedByPdev(const VkPhysicalDevice physical_device, const std::string ext_name) const { |
| 101 | if (instance_extensions.vk_khr_get_physical_device_properties_2) { |
| 102 | // Struct is legal IF it's supported |
| 103 | const auto &dev_exts_enumerated = device_extensions_enumerated.find(physical_device); |
| 104 | if (dev_exts_enumerated == device_extensions_enumerated.end()) return true; |
| 105 | auto enum_iter = dev_exts_enumerated->second.find(ext_name); |
| 106 | if (enum_iter != dev_exts_enumerated->second.cend()) { |
| 107 | return true; |
| 108 | } |
| 109 | } |
| 110 | return false; |
| 111 | } |
| 112 | |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 113 | bool StatelessValidation::validate_validation_features(const VkInstanceCreateInfo *pCreateInfo, |
| 114 | const VkValidationFeaturesEXT *validation_features) const { |
| 115 | bool skip = false; |
| 116 | bool debug_printf = false; |
| 117 | bool gpu_assisted = false; |
| 118 | bool reserve_slot = false; |
| 119 | for (uint32_t i = 0; i < validation_features->enabledValidationFeatureCount; i++) { |
| 120 | switch (validation_features->pEnabledValidationFeatures[i]) { |
| 121 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT: |
| 122 | gpu_assisted = true; |
| 123 | break; |
| 124 | |
| 125 | case VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT: |
| 126 | debug_printf = true; |
| 127 | break; |
| 128 | |
| 129 | case VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT: |
| 130 | reserve_slot = true; |
| 131 | break; |
| 132 | |
| 133 | default: |
| 134 | break; |
| 135 | } |
| 136 | } |
| 137 | if (reserve_slot && !gpu_assisted) { |
| 138 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02967", |
| 139 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT is in pEnabledValidationFeatures, " |
| 140 | "VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT must also be in pEnabledValidationFeatures."); |
| 141 | } |
| 142 | if (gpu_assisted && debug_printf) { |
| 143 | skip |= LogError(instance, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-02968", |
| 144 | "If VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT is in pEnabledValidationFeatures, " |
| 145 | "VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT must not also be in pEnabledValidationFeatures."); |
| 146 | } |
| 147 | |
| 148 | return skip; |
| 149 | } |
| 150 | |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 151 | template <typename ExtensionState> |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 152 | ExtEnabled extension_state_by_name(const ExtensionState &extensions, const char *extension_name) { |
| 153 | if (!extension_name) return kNotEnabled; // null strings specify nothing |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 154 | auto info = ExtensionState::get_info(extension_name); |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 155 | ExtEnabled state = |
| 156 | info.state ? extensions.*(info.state) : kNotEnabled; // unknown extensions can't be enabled in extension struct |
John Zulauf | 620755c | 2018-04-16 11:00:43 -0600 | [diff] [blame] | 157 | return state; |
| 158 | } |
| 159 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 160 | bool StatelessValidation::manual_PreCallValidateCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 161 | const VkAllocationCallbacks *pAllocator, |
| 162 | VkInstance *pInstance) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 163 | bool skip = false; |
| 164 | // Note: From the spec-- |
| 165 | // Providing a NULL VkInstanceCreateInfo::pApplicationInfo or providing an apiVersion of 0 is equivalent to providing |
| 166 | // an apiVersion of VK_MAKE_VERSION(1, 0, 0). (a.k.a. VK_API_VERSION_1_0) |
| 167 | uint32_t local_api_version = (pCreateInfo->pApplicationInfo && pCreateInfo->pApplicationInfo->apiVersion) |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 168 | ? pCreateInfo->pApplicationInfo->apiVersion |
| 169 | : VK_API_VERSION_1_0; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 170 | skip |= validate_api_version(local_api_version, api_version); |
| 171 | skip |= validate_instance_extensions(pCreateInfo); |
Tony-LunarG | 866843d | 2020-05-13 11:22:42 -0600 | [diff] [blame] | 172 | const auto *validation_features = lvl_find_in_chain<VkValidationFeaturesEXT>(pCreateInfo->pNext); |
| 173 | if (validation_features) skip |= validate_validation_features(pCreateInfo, validation_features); |
| 174 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 175 | return skip; |
| 176 | } |
| 177 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 178 | void StatelessValidation::PostCallRecordCreateInstance(const VkInstanceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 179 | const VkAllocationCallbacks *pAllocator, VkInstance *pInstance, |
| 180 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 181 | auto instance_data = GetLayerDataPtr(get_dispatch_key(*pInstance), layer_data_map); |
| 182 | // Copy extension data into local object |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 183 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 184 | this->instance_extensions = instance_data->instance_extensions; |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 185 | |
| 186 | uint32_t pdev_count = 0; |
| 187 | DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, nullptr); |
| 188 | std::vector<VkPhysicalDevice> physical_devices; |
| 189 | physical_devices.resize(pdev_count); |
| 190 | DispatchEnumeratePhysicalDevices(*pInstance, &pdev_count, physical_devices.data()); |
| 191 | |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 192 | for (uint32_t i = 0; i < physical_devices.size(); i++) { |
| 193 | auto phys_dev_props = new VkPhysicalDeviceProperties; |
| 194 | DispatchGetPhysicalDeviceProperties(physical_devices[i], phys_dev_props); |
| 195 | physical_device_properties_map[physical_devices[i]] = phys_dev_props; |
Mark Lobodzinski | bece6c1 | 2020-08-27 15:34:02 -0600 | [diff] [blame] | 196 | |
| 197 | // Enumerate the Device Ext Properties to save the PhysicalDevice supported extension state |
| 198 | uint32_t ext_count = 0; |
| 199 | std::unordered_set<std::string> dev_exts_enumerated{}; |
| 200 | std::vector<VkExtensionProperties> ext_props{}; |
| 201 | instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, nullptr); |
| 202 | ext_props.resize(ext_count); |
| 203 | instance_dispatch_table.EnumerateDeviceExtensionProperties(physical_devices[i], nullptr, &ext_count, ext_props.data()); |
| 204 | for (uint32_t j = 0; j < ext_count; j++) { |
| 205 | dev_exts_enumerated.insert(ext_props[j].extensionName); |
| 206 | } |
| 207 | device_extensions_enumerated[physical_devices[i]] = std::move(dev_exts_enumerated); |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 208 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 209 | } |
| 210 | |
Mark Lobodzinski | 2e40a13 | 2020-08-10 14:51:41 -0600 | [diff] [blame] | 211 | void StatelessValidation::PreCallRecordDestroyInstance(VkInstance instance, const VkAllocationCallbacks *pAllocator) { |
| 212 | for (auto it = physical_device_properties_map.begin(); it != physical_device_properties_map.end();) { |
| 213 | delete (it->second); |
| 214 | it = physical_device_properties_map.erase(it); |
| 215 | } |
| 216 | }; |
| 217 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 218 | void StatelessValidation::PostCallRecordCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 219 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice, VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 220 | auto device_data = GetLayerDataPtr(get_dispatch_key(*pDevice), layer_data_map); |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 221 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 222 | ValidationObject *validation_data = GetValidationObject(device_data->object_dispatch, LayerObjectTypeParameterValidation); |
| 223 | StatelessValidation *stateless_validation = static_cast<StatelessValidation *>(validation_data); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 224 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 225 | // Parmeter validation also uses extension data |
| 226 | stateless_validation->device_extensions = this->device_extensions; |
| 227 | |
| 228 | VkPhysicalDeviceProperties device_properties = {}; |
| 229 | // Need to get instance and do a getlayerdata call... |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 230 | DispatchGetPhysicalDeviceProperties(physicalDevice, &device_properties); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 231 | memcpy(&stateless_validation->device_limits, &device_properties.limits, sizeof(VkPhysicalDeviceLimits)); |
| 232 | |
| 233 | if (device_extensions.vk_nv_shading_rate_image) { |
| 234 | // Get the needed shading rate image limits |
| 235 | auto shading_rate_image_props = lvl_init_struct<VkPhysicalDeviceShadingRateImagePropertiesNV>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 236 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&shading_rate_image_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 237 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 238 | phys_dev_ext_props.shading_rate_image_props = shading_rate_image_props; |
| 239 | } |
| 240 | |
| 241 | if (device_extensions.vk_nv_mesh_shader) { |
| 242 | // Get the needed mesh shader limits |
| 243 | auto mesh_shader_props = lvl_init_struct<VkPhysicalDeviceMeshShaderPropertiesNV>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 244 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&mesh_shader_props); |
Tony-LunarG | 152a88b | 2019-03-20 15:42:24 -0600 | [diff] [blame] | 245 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 246 | phys_dev_ext_props.mesh_shader_props = mesh_shader_props; |
| 247 | } |
| 248 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 249 | if (device_extensions.vk_nv_ray_tracing) { |
| 250 | // Get the needed ray tracing limits |
| 251 | auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPropertiesNV>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 252 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&ray_tracing_props); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 253 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 254 | phys_dev_ext_props.ray_tracing_propsNV = ray_tracing_props; |
| 255 | } |
| 256 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 257 | if (device_extensions.vk_khr_ray_tracing_pipeline) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 258 | // Get the needed ray tracing limits |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 259 | auto ray_tracing_props = lvl_init_struct<VkPhysicalDeviceRayTracingPipelinePropertiesKHR>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 260 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&ray_tracing_props); |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 261 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 262 | phys_dev_ext_props.ray_tracing_propsKHR = ray_tracing_props; |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 263 | } |
| 264 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 265 | if (device_extensions.vk_khr_acceleration_structure) { |
| 266 | // Get the needed ray tracing acc structure limits |
| 267 | auto acc_structure_props = lvl_init_struct<VkPhysicalDeviceAccelerationStructurePropertiesKHR>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 268 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&acc_structure_props); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 269 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 270 | phys_dev_ext_props.acc_structure_props = acc_structure_props; |
| 271 | } |
| 272 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 273 | if (device_extensions.vk_ext_transform_feedback) { |
| 274 | // Get the needed transform feedback limits |
| 275 | auto transform_feedback_props = lvl_init_struct<VkPhysicalDeviceTransformFeedbackPropertiesEXT>(); |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 276 | auto prop2 = lvl_init_struct<VkPhysicalDeviceProperties2>(&transform_feedback_props); |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 277 | DispatchGetPhysicalDeviceProperties2KHR(physicalDevice, &prop2); |
| 278 | phys_dev_ext_props.transform_feedback_props = transform_feedback_props; |
| 279 | } |
| 280 | |
Jasper St. Pierre | a49b4be | 2019-02-05 17:48:57 -0800 | [diff] [blame] | 281 | stateless_validation->phys_dev_ext_props = this->phys_dev_ext_props; |
| 282 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 283 | // Save app-enabled features in this device's validation object |
| 284 | // The enabled features can come from either pEnabledFeatures, or from the pNext chain |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 285 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
| 286 | safe_VkPhysicalDeviceFeatures2 tmp_features2_state; |
| 287 | tmp_features2_state.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FEATURES_2; |
| 288 | if (features2) { |
| 289 | tmp_features2_state.features = features2->features; |
| 290 | } else if (pCreateInfo->pEnabledFeatures) { |
| 291 | tmp_features2_state.features = *pCreateInfo->pEnabledFeatures; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 292 | } else { |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 293 | tmp_features2_state.features = {}; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 294 | } |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 295 | // Use pCreateInfo->pNext to get full chain |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 296 | stateless_validation->device_createinfo_pnext = SafePnextCopy(pCreateInfo->pNext); |
Petr Kraus | 715bcc7 | 2019-08-15 17:17:33 +0200 | [diff] [blame] | 297 | stateless_validation->physical_device_features2 = tmp_features2_state; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 298 | } |
| 299 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 300 | bool StatelessValidation::manual_PreCallValidateCreateDevice(VkPhysicalDevice physicalDevice, const VkDeviceCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 301 | const VkAllocationCallbacks *pAllocator, VkDevice *pDevice) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 302 | bool skip = false; |
| 303 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 304 | for (size_t i = 0; i < pCreateInfo->enabledLayerCount; i++) { |
| 305 | skip |= validate_string("vkCreateDevice", "pCreateInfo->ppEnabledLayerNames", |
| 306 | "VUID-VkDeviceCreateInfo-ppEnabledLayerNames-parameter", pCreateInfo->ppEnabledLayerNames[i]); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 307 | } |
| 308 | |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 309 | // If this device supports VK_KHR_portability_subset, it must be enabled |
| 310 | const std::string portability_extension_name("VK_KHR_portability_subset"); |
| 311 | const auto &dev_extensions = device_extensions_enumerated.at(physicalDevice); |
| 312 | const bool portability_supported = dev_extensions.count(portability_extension_name) != 0; |
| 313 | bool portability_requested = false; |
| 314 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 315 | for (size_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 316 | skip |= |
| 317 | validate_string("vkCreateDevice", "pCreateInfo->ppEnabledExtensionNames", |
| 318 | "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-parameter", pCreateInfo->ppEnabledExtensionNames[i]); |
| 319 | skip |= validate_extension_reqs(device_extensions, "VUID-vkCreateDevice-ppEnabledExtensionNames-01387", "device", |
| 320 | pCreateInfo->ppEnabledExtensionNames[i]); |
Nathaniel Cesario | b3f2d70 | 2020-11-09 09:20:49 -0700 | [diff] [blame] | 321 | if (portability_extension_name == pCreateInfo->ppEnabledExtensionNames[i]) { |
| 322 | portability_requested = true; |
| 323 | } |
| 324 | } |
| 325 | |
| 326 | if (portability_supported && !portability_requested) { |
| 327 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-pProperties-04451", |
| 328 | "vkCreateDevice: VK_KHR_portability_subset must be enabled because physical device %s supports it", |
| 329 | report_data->FormatHandle(physicalDevice).c_str()); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 330 | } |
| 331 | |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 332 | { |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 333 | bool maint1 = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_MAINTENANCE1_EXTENSION_NAME)); |
| 334 | bool negative_viewport = |
| 335 | IsExtEnabled(extension_state_by_name(device_extensions, VK_AMD_NEGATIVE_VIEWPORT_HEIGHT_EXTENSION_NAME)); |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 336 | if (maint1 && negative_viewport) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 337 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-00374", |
| 338 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not simultaneously include VK_KHR_maintenance1 and " |
| 339 | "VK_AMD_negative_viewport_height."); |
Petr Kraus | 6c4bdce | 2019-08-27 17:35:01 +0200 | [diff] [blame] | 340 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 341 | } |
| 342 | |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 343 | { |
| 344 | bool khr_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_KHR_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 345 | bool ext_bda = IsExtEnabled(extension_state_by_name(device_extensions, VK_EXT_BUFFER_DEVICE_ADDRESS_EXTENSION_NAME)); |
| 346 | if (khr_bda && ext_bda) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 347 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-ppEnabledExtensionNames-03328", |
| 348 | "VkDeviceCreateInfo->ppEnabledExtensionNames must not contain both VK_KHR_buffer_device_address and " |
| 349 | "VK_EXT_buffer_device_address."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 350 | } |
| 351 | } |
| 352 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 353 | if (pCreateInfo->pNext != NULL && pCreateInfo->pEnabledFeatures) { |
| 354 | // Check for get_physical_device_properties2 struct |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 355 | const auto *features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 356 | if (features2) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 357 | // Cannot include VkPhysicalDeviceFeatures2 and have non-null pEnabledFeatures |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 358 | skip |= LogError(device, "VUID-VkDeviceCreateInfo-pNext-00373", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 359 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceFeatures2 struct when " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 360 | "pCreateInfo->pEnabledFeatures is non-NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 361 | } |
| 362 | } |
| 363 | |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 364 | auto features2 = lvl_find_in_chain<VkPhysicalDeviceFeatures2>(pCreateInfo->pNext); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 365 | const VkPhysicalDeviceFeatures *features = features2 ? &features2->features : pCreateInfo->pEnabledFeatures; |
| 366 | const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(pCreateInfo->pNext); |
| 367 | if (features && robustness2_features && robustness2_features->robustBufferAccess2 && !features->robustBufferAccess) { |
| 368 | skip |= LogError(device, "VUID-VkPhysicalDeviceRobustness2FeaturesEXT-robustBufferAccess2-04000", |
| 369 | "If robustBufferAccess2 is enabled then robustBufferAccess must be enabled."); |
| 370 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 371 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(pCreateInfo->pNext); |
| 372 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplayMixed && |
| 373 | !raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay) { |
| 374 | skip |= LogError( |
| 375 | device, |
| 376 | "VUID-VkPhysicalDeviceRayTracingPipelineFeaturesKHR-rayTracingPipelineShaderGroupHandleCaptureReplayMixed-03575", |
| 377 | "If rayTracingPipelineShaderGroupHandleCaptureReplayMixed is VK_TRUE, rayTracingPipelineShaderGroupHandleCaptureReplay " |
| 378 | "must also be VK_TRUE."); |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 379 | } |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 380 | auto vertex_attribute_divisor_features = |
| 381 | lvl_find_in_chain<VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT>(pCreateInfo->pNext); |
Mark Lobodzinski | 3e66ae8 | 2020-08-12 16:27:29 -0600 | [diff] [blame] | 382 | if (vertex_attribute_divisor_features && (!device_extensions.vk_ext_vertex_attribute_divisor)) { |
| 383 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 384 | "VkDeviceCreateInfo->pNext includes a VkPhysicalDeviceVertexAttributeDivisorFeaturesEXT " |
| 385 | "struct, VK_EXT_vertex_attribute_divisor must be enabled when it creates a device."); |
Locke | 77fad1c | 2019-04-16 13:09:03 -0600 | [diff] [blame] | 386 | } |
| 387 | |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 388 | const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(pCreateInfo->pNext); |
| 389 | if (vulkan_11_features) { |
| 390 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 391 | while (current) { |
| 392 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_16BIT_STORAGE_FEATURES || |
| 393 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_MULTIVIEW_FEATURES || |
| 394 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VARIABLE_POINTERS_FEATURES || |
| 395 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PROTECTED_MEMORY_FEATURES || |
| 396 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SAMPLER_YCBCR_CONVERSION_FEATURES || |
| 397 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_DRAW_PARAMETERS_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 398 | skip |= LogError( |
| 399 | instance, "VUID-VkDeviceCreateInfo-pNext-02829", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 400 | "If the pNext chain includes a VkPhysicalDeviceVulkan11Features structure, then it must not include a " |
| 401 | "VkPhysicalDevice16BitStorageFeatures, VkPhysicalDeviceMultiviewFeatures, " |
| 402 | "VkPhysicalDeviceVariablePointersFeatures, VkPhysicalDeviceProtectedMemoryFeatures, " |
| 403 | "VkPhysicalDeviceSamplerYcbcrConversionFeatures, or VkPhysicalDeviceShaderDrawParametersFeatures structure"); |
| 404 | break; |
| 405 | } |
| 406 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 407 | } |
| 408 | } |
| 409 | |
| 410 | const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(pCreateInfo->pNext); |
| 411 | if (vulkan_12_features) { |
| 412 | const VkBaseOutStructure *current = reinterpret_cast<const VkBaseOutStructure *>(pCreateInfo->pNext); |
| 413 | while (current) { |
| 414 | if (current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_8BIT_STORAGE_FEATURES || |
| 415 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_ATOMIC_INT64_FEATURES || |
| 416 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_FLOAT16_INT8_FEATURES || |
| 417 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_DESCRIPTOR_INDEXING_FEATURES || |
| 418 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SCALAR_BLOCK_LAYOUT_FEATURES || |
| 419 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_IMAGELESS_FRAMEBUFFER_FEATURES || |
| 420 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_UNIFORM_BUFFER_STANDARD_LAYOUT_FEATURES || |
| 421 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SHADER_SUBGROUP_EXTENDED_TYPES_FEATURES || |
| 422 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SEPARATE_DEPTH_STENCIL_LAYOUTS_FEATURES || |
| 423 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_HOST_QUERY_RESET_FEATURES || |
| 424 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_TIMELINE_SEMAPHORE_FEATURES || |
| 425 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_BUFFER_DEVICE_ADDRESS_FEATURES || |
| 426 | current->sType == VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_VULKAN_MEMORY_MODEL_FEATURES) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 427 | skip |= LogError( |
| 428 | instance, "VUID-VkDeviceCreateInfo-pNext-02830", |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 429 | "If the pNext chain includes a VkPhysicalDeviceVulkan12Features structure, then it must not include a " |
| 430 | "VkPhysicalDevice8BitStorageFeatures, VkPhysicalDeviceShaderAtomicInt64Features, " |
| 431 | "VkPhysicalDeviceShaderFloat16Int8Features, VkPhysicalDeviceDescriptorIndexingFeatures, " |
| 432 | "VkPhysicalDeviceScalarBlockLayoutFeatures, VkPhysicalDeviceImagelessFramebufferFeatures, " |
| 433 | "VkPhysicalDeviceUniformBufferStandardLayoutFeatures, VkPhysicalDeviceShaderSubgroupExtendedTypesFeatures, " |
| 434 | "VkPhysicalDeviceSeparateDepthStencilLayoutsFeatures, VkPhysicalDeviceHostQueryResetFeatures, " |
| 435 | "VkPhysicalDeviceTimelineSemaphoreFeatures, VkPhysicalDeviceBufferDeviceAddressFeatures, or " |
| 436 | "VkPhysicalDeviceVulkanMemoryModelFeatures structure"); |
| 437 | break; |
| 438 | } |
| 439 | current = reinterpret_cast<const VkBaseOutStructure *>(current->pNext); |
| 440 | } |
sfricke-samsung | abab463 | 2020-05-04 06:51:46 -0700 | [diff] [blame] | 441 | // Check features are enabled if matching extension is passed in as well |
| 442 | for (uint32_t i = 0; i < pCreateInfo->enabledExtensionCount; i++) { |
| 443 | const char *extension = pCreateInfo->ppEnabledExtensionNames[i]; |
| 444 | if ((0 == strncmp(extension, VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 445 | (vulkan_12_features->drawIndirectCount == VK_FALSE)) { |
| 446 | skip |= LogError( |
| 447 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02831", |
| 448 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::drawIndirectCount is not VK_TRUE.", |
| 449 | VK_KHR_DRAW_INDIRECT_COUNT_EXTENSION_NAME); |
| 450 | } |
| 451 | if ((0 == strncmp(extension, VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 452 | (vulkan_12_features->samplerMirrorClampToEdge == VK_FALSE)) { |
| 453 | skip |= LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02832", |
| 454 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerMirrorClampToEdge " |
| 455 | "is not VK_TRUE.", |
| 456 | VK_KHR_SAMPLER_MIRROR_CLAMP_TO_EDGE_EXTENSION_NAME); |
| 457 | } |
| 458 | if ((0 == strncmp(extension, VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 459 | (vulkan_12_features->descriptorIndexing == VK_FALSE)) { |
| 460 | skip |= LogError( |
| 461 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02833", |
| 462 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::descriptorIndexing is not VK_TRUE.", |
| 463 | VK_EXT_DESCRIPTOR_INDEXING_EXTENSION_NAME); |
| 464 | } |
| 465 | if ((0 == strncmp(extension, VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 466 | (vulkan_12_features->samplerFilterMinmax == VK_FALSE)) { |
| 467 | skip |= LogError( |
| 468 | instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02834", |
| 469 | "vkCreateDevice(): %s is enabled but VkPhysicalDeviceVulkan12Features::samplerFilterMinmax is not VK_TRUE.", |
| 470 | VK_EXT_SAMPLER_FILTER_MINMAX_EXTENSION_NAME); |
| 471 | } |
| 472 | if ((0 == strncmp(extension, VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME, VK_MAX_EXTENSION_NAME_SIZE)) && |
| 473 | ((vulkan_12_features->shaderOutputViewportIndex == VK_FALSE) || |
| 474 | (vulkan_12_features->shaderOutputLayer == VK_FALSE))) { |
| 475 | skip |= |
| 476 | LogError(instance, "VUID-VkDeviceCreateInfo-ppEnabledExtensions-02835", |
| 477 | "vkCreateDevice(): %s is enabled but both VkPhysicalDeviceVulkan12Features::shaderOutputViewportIndex " |
| 478 | "and VkPhysicalDeviceVulkan12Features::shaderOutputLayer are not VK_TRUE.", |
| 479 | VK_EXT_SHADER_VIEWPORT_INDEX_LAYER_EXTENSION_NAME); |
| 480 | } |
| 481 | } |
Tony-LunarG | 28017bc | 2020-01-23 14:40:25 -0700 | [diff] [blame] | 482 | } |
| 483 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 484 | // Validate pCreateInfo->pQueueCreateInfos |
| 485 | if (pCreateInfo->pQueueCreateInfos) { |
| 486 | std::unordered_set<uint32_t> set; |
| 487 | |
| 488 | for (uint32_t i = 0; i < pCreateInfo->queueCreateInfoCount; ++i) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 489 | const VkDeviceQueueCreateInfo &queue_create_info = pCreateInfo->pQueueCreateInfos[i]; |
| 490 | const uint32_t requested_queue_family = queue_create_info.queueFamilyIndex; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 491 | if (requested_queue_family == VK_QUEUE_FAMILY_IGNORED) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 492 | skip |= |
| 493 | LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-queueFamilyIndex-00381", |
| 494 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 |
| 495 | "].queueFamilyIndex is VK_QUEUE_FAMILY_IGNORED, but it is required to provide a valid queue family " |
| 496 | "index value.", |
| 497 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 498 | } else if (set.count(requested_queue_family)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 499 | skip |= LogError(physicalDevice, "VUID-VkDeviceCreateInfo-queueFamilyIndex-00372", |
| 500 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].queueFamilyIndex (=%" PRIu32 |
| 501 | ") is not unique within pCreateInfo->pQueueCreateInfos array.", |
| 502 | i, requested_queue_family); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 503 | } else { |
| 504 | set.insert(requested_queue_family); |
| 505 | } |
| 506 | |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 507 | if (queue_create_info.pQueuePriorities != nullptr) { |
| 508 | for (uint32_t j = 0; j < queue_create_info.queueCount; ++j) { |
| 509 | const float queue_priority = queue_create_info.pQueuePriorities[j]; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 510 | if (!(queue_priority >= 0.f) || !(queue_priority <= 1.f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 511 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-pQueuePriorities-00383", |
| 512 | "vkCreateDevice: pCreateInfo->pQueueCreateInfos[%" PRIu32 "].pQueuePriorities[%" PRIu32 |
| 513 | "] (=%f) is not between 0 and 1 (inclusive).", |
| 514 | i, j, queue_priority); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 515 | } |
| 516 | } |
| 517 | } |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 518 | |
| 519 | // Need to know if protectedMemory feature is passed in preCall to creating the device |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 520 | VkBool32 protected_memory = VK_FALSE; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 521 | const VkPhysicalDeviceProtectedMemoryFeatures *protected_features = |
| 522 | lvl_find_in_chain<VkPhysicalDeviceProtectedMemoryFeatures>(pCreateInfo->pNext); |
| 523 | if (protected_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 524 | protected_memory = protected_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 525 | } else if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 526 | protected_memory = vulkan_11_features->protectedMemory; |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 527 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 528 | if ((queue_create_info.flags == VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT) && (protected_memory == VK_FALSE)) { |
sfricke-samsung | 590ae1e | 2020-04-25 01:18:05 -0700 | [diff] [blame] | 529 | skip |= LogError(physicalDevice, "VUID-VkDeviceQueueCreateInfo-flags-02861", |
| 530 | "vkCreateDevice: pCreateInfo->flags set to VK_DEVICE_QUEUE_CREATE_PROTECTED_BIT without the " |
| 531 | "protectedMemory feature being set as well."); |
| 532 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 533 | } |
| 534 | } |
| 535 | |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 536 | // feature dependencies for VK_KHR_variable_pointers |
| 537 | const auto *variable_pointers_features = lvl_find_in_chain<VkPhysicalDeviceVariablePointersFeatures>(pCreateInfo->pNext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 538 | VkBool32 variable_pointers = VK_FALSE; |
| 539 | VkBool32 variable_pointers_storage_buffer = VK_FALSE; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 540 | if (vulkan_11_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 541 | variable_pointers = vulkan_11_features->variablePointers; |
| 542 | variable_pointers_storage_buffer = vulkan_11_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 543 | } else if (variable_pointers_features) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 544 | variable_pointers = variable_pointers_features->variablePointers; |
| 545 | variable_pointers_storage_buffer = variable_pointers_features->variablePointersStorageBuffer; |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 546 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 547 | if ((variable_pointers == VK_TRUE) && (variable_pointers_storage_buffer == VK_FALSE)) { |
sfricke-samsung | 30a5741 | 2020-05-15 21:14:54 -0700 | [diff] [blame] | 548 | skip |= LogError(instance, "VUID-VkPhysicalDeviceVariablePointersFeatures-variablePointers-01431", |
| 549 | "If variablePointers is VK_TRUE then variablePointersStorageBuffer also needs to be VK_TRUE"); |
| 550 | } |
| 551 | |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 552 | // feature dependencies for VK_KHR_multiview |
| 553 | const auto *multiview_features = lvl_find_in_chain<VkPhysicalDeviceMultiviewFeatures>(pCreateInfo->pNext); |
| 554 | VkBool32 multiview = VK_FALSE; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 555 | VkBool32 multiview_geometry_shader = VK_FALSE; |
| 556 | VkBool32 multiview_tessellation_shader = VK_FALSE; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 557 | if (vulkan_11_features) { |
| 558 | multiview = vulkan_11_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 559 | multiview_geometry_shader = vulkan_11_features->multiviewGeometryShader; |
| 560 | multiview_tessellation_shader = vulkan_11_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 561 | } else if (multiview_features) { |
| 562 | multiview = multiview_features->multiview; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 563 | multiview_geometry_shader = multiview_features->multiviewGeometryShader; |
| 564 | multiview_tessellation_shader = multiview_features->multiviewTessellationShader; |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 565 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 566 | if ((multiview == VK_FALSE) && (multiview_geometry_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 567 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewGeometryShader-00580", |
| 568 | "If multiviewGeometryShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 569 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 570 | if ((multiview == VK_FALSE) && (multiview_tessellation_shader == VK_TRUE)) { |
sfricke-samsung | fd76c34 | 2020-05-29 23:13:43 -0700 | [diff] [blame] | 571 | skip |= LogError(instance, "VUID-VkPhysicalDeviceMultiviewFeatures-multiviewTessellationShader-00581", |
| 572 | "If multiviewTessellationShader is VK_TRUE then multiview also needs to be VK_TRUE"); |
| 573 | } |
| 574 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 575 | return skip; |
| 576 | } |
| 577 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 578 | bool StatelessValidation::require_device_extension(bool flag, char const *function_name, char const *extension_name) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 579 | if (!flag) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 580 | return LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 581 | "%s() called even though the %s extension was not enabled for this VkDevice.", function_name, |
| 582 | extension_name); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 583 | } |
| 584 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 585 | return false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 586 | } |
| 587 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 588 | bool StatelessValidation::manual_PreCallValidateCreateBuffer(VkDevice device, const VkBufferCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 589 | const VkAllocationCallbacks *pAllocator, VkBuffer *pBuffer) const { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 590 | bool skip = false; |
| 591 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 592 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 593 | skip |= |
| 594 | ValidateGreaterThanZero(pCreateInfo->size, "pCreateInfo->size", "VUID-VkBufferCreateInfo-size-00912", "vkCreateBuffer"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 595 | |
| 596 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 597 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 598 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 599 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 600 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00914", |
| 601 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 602 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 603 | } |
| 604 | |
| 605 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 606 | // queueFamilyIndexCount uint32_t values |
| 607 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 608 | skip |= LogError(device, "VUID-VkBufferCreateInfo-sharingMode-00913", |
| 609 | "vkCreateBuffer: if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 610 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 611 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 612 | } |
| 613 | } |
| 614 | |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 615 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) { |
| 616 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00915", |
| 617 | "vkCreateBuffer(): the sparseBinding device feature is disabled: Buffers cannot be created with the " |
| 618 | "VK_BUFFER_CREATE_SPARSE_BINDING_BIT set."); |
| 619 | } |
| 620 | |
| 621 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT) && (!physical_device_features.sparseResidencyBuffer)) { |
| 622 | skip |= |
| 623 | LogError(device, "VUID-VkBufferCreateInfo-flags-00916", |
| 624 | "vkCreateBuffer(): the sparseResidencyBuffer device feature is disabled: Buffers cannot be created with " |
| 625 | "the VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT set."); |
| 626 | } |
| 627 | |
| 628 | if ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
| 629 | skip |= |
| 630 | LogError(device, "VUID-VkBufferCreateInfo-flags-00917", |
| 631 | "vkCreateBuffer(): the sparseResidencyAliased device feature is disabled: Buffers cannot be created with " |
| 632 | "the VK_BUFFER_CREATE_SPARSE_ALIASED_BIT set."); |
| 633 | } |
| 634 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 635 | // If flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 636 | // VK_BUFFER_CREATE_SPARSE_BINDING_BIT |
| 637 | if (((pCreateInfo->flags & (VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT | VK_BUFFER_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 638 | ((pCreateInfo->flags & VK_BUFFER_CREATE_SPARSE_BINDING_BIT) != VK_BUFFER_CREATE_SPARSE_BINDING_BIT)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 639 | skip |= LogError(device, "VUID-VkBufferCreateInfo-flags-00918", |
| 640 | "vkCreateBuffer: if pCreateInfo->flags contains VK_BUFFER_CREATE_SPARSE_RESIDENCY_BIT or " |
| 641 | "VK_BUFFER_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_BUFFER_CREATE_SPARSE_BINDING_BIT."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 642 | } |
| 643 | } |
| 644 | |
| 645 | return skip; |
| 646 | } |
| 647 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 648 | bool StatelessValidation::manual_PreCallValidateCreateImage(VkDevice device, const VkImageCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 649 | const VkAllocationCallbacks *pAllocator, VkImage *pImage) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 650 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 651 | |
| 652 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 653 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 654 | if (pCreateInfo->sharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 655 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 656 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 657 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00942", |
| 658 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 659 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 660 | } |
| 661 | |
| 662 | // If sharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 663 | // queueFamilyIndexCount uint32_t values |
| 664 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 665 | skip |= LogError(device, "VUID-VkImageCreateInfo-sharingMode-00941", |
| 666 | "vkCreateImage(): if pCreateInfo->sharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 667 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 668 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 669 | } |
| 670 | } |
| 671 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 672 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.width, "pCreateInfo->extent.width", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 673 | "VUID-VkImageCreateInfo-extent-00944", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 674 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.height, "pCreateInfo->extent.height", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 675 | "VUID-VkImageCreateInfo-extent-00945", "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 676 | skip |= ValidateGreaterThanZero(pCreateInfo->extent.depth, "pCreateInfo->extent.depth", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 677 | "VUID-VkImageCreateInfo-extent-00946", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 678 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 679 | skip |= ValidateGreaterThanZero(pCreateInfo->mipLevels, "pCreateInfo->mipLevels", "VUID-VkImageCreateInfo-mipLevels-00947", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 680 | "vkCreateImage"); |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 681 | skip |= ValidateGreaterThanZero(pCreateInfo->arrayLayers, "pCreateInfo->arrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 682 | "VUID-VkImageCreateInfo-arrayLayers-00948", "vkCreateImage"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 683 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 684 | // InitialLayout must be PREINITIALIZED or UNDEFINED |
Dave Houlton | e19e20d | 2018-02-02 16:32:41 -0700 | [diff] [blame] | 685 | if ((pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) && |
| 686 | (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_PREINITIALIZED)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 687 | skip |= LogError( |
| 688 | device, "VUID-VkImageCreateInfo-initialLayout-00993", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 689 | "vkCreateImage(): initialLayout is %s, must be VK_IMAGE_LAYOUT_UNDEFINED or VK_IMAGE_LAYOUT_PREINITIALIZED.", |
| 690 | string_VkImageLayout(pCreateInfo->initialLayout)); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 691 | } |
| 692 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 693 | // If imageType is VK_IMAGE_TYPE_1D, both extent.height and extent.depth must be 1 |
Petr Kraus | 3ac9e81 | 2018-03-13 12:31:08 +0100 | [diff] [blame] | 694 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_1D) && |
| 695 | ((pCreateInfo->extent.height != 1) || (pCreateInfo->extent.depth != 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 696 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00956", |
| 697 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_1D, both pCreateInfo->extent.height and " |
| 698 | "pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 699 | } |
| 700 | |
| 701 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D) { |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 702 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 703 | if (pCreateInfo->extent.width != pCreateInfo->extent.height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 704 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 705 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 706 | "pCreateInfo->extent.width (=%" PRIu32 ") and pCreateInfo->extent.height (=%" PRIu32 |
| 707 | ") are not equal.", |
| 708 | pCreateInfo->extent.width, pCreateInfo->extent.height); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 709 | } |
| 710 | |
| 711 | if (pCreateInfo->arrayLayers < 6) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 712 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00954", |
| 713 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT, but " |
| 714 | "pCreateInfo->arrayLayers (=%" PRIu32 ") is not greater than or equal to 6.", |
| 715 | pCreateInfo->arrayLayers); |
Petr Kraus | 3f43321 | 2018-03-13 12:31:27 +0100 | [diff] [blame] | 716 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 717 | } |
| 718 | |
| 719 | if (pCreateInfo->extent.depth != 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 720 | skip |= LogError( |
| 721 | device, "VUID-VkImageCreateInfo-imageType-00957", |
| 722 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_2D, pCreateInfo->extent.depth must be 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 723 | } |
| 724 | } |
| 725 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 726 | // 3D image may have only 1 layer |
| 727 | if ((pCreateInfo->imageType == VK_IMAGE_TYPE_3D) && (pCreateInfo->arrayLayers != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 728 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00961", |
| 729 | "vkCreateImage(): if pCreateInfo->imageType is VK_IMAGE_TYPE_3D, pCreateInfo->arrayLayers must be 1."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 730 | } |
| 731 | |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 732 | if (0 != (pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT)) { |
| 733 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_COLOR_ATTACHMENT_BIT | VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | |
| 734 | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 735 | // At least one of the legal attachment bits must be set |
| 736 | if (0 == (pCreateInfo->usage & legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 737 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00966", |
| 738 | "vkCreateImage(): Transient attachment image without a compatible attachment flag set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 739 | } |
| 740 | // No flags other than the legal attachment bits may be set |
| 741 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 742 | if (0 != (pCreateInfo->usage & ~legal_flags)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 743 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00963", |
| 744 | "vkCreateImage(): Transient attachment image with incompatible usage flags set."); |
Dave Houlton | 130c021 | 2018-01-29 13:39:56 -0700 | [diff] [blame] | 745 | } |
| 746 | } |
| 747 | |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 748 | // mipLevels must be less than or equal to the number of levels in the complete mipmap chain |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 749 | uint32_t max_dim = std::max(std::max(pCreateInfo->extent.width, pCreateInfo->extent.height), pCreateInfo->extent.depth); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 750 | // Max mip levels is different for corner-sampled images vs normal images. |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 751 | uint32_t max_mip_levels = (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) |
| 752 | ? static_cast<uint32_t>(ceil(log2(max_dim))) |
| 753 | : static_cast<uint32_t>(floor(log2(max_dim)) + 1); |
| 754 | if (max_dim > 0 && pCreateInfo->mipLevels > max_mip_levels) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 755 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 756 | LogError(device, "VUID-VkImageCreateInfo-mipLevels-00958", |
| 757 | "vkCreateImage(): pCreateInfo->mipLevels must be less than or equal to " |
| 758 | "floor(log2(max(pCreateInfo->extent.width, pCreateInfo->extent.height, pCreateInfo->extent.depth)))+1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 759 | } |
| 760 | |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 761 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT) && (pCreateInfo->imageType != VK_IMAGE_TYPE_3D)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 762 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00950", |
| 763 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_2D_ARRAY_COMPATIBLE_BIT but " |
| 764 | "pCreateInfo->imageType is not VK_IMAGE_TYPE_3D."); |
Mark Lobodzinski | 69259c5 | 2018-09-18 15:14:58 -0600 | [diff] [blame] | 765 | } |
| 766 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 767 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) && (!physical_device_features.sparseBinding)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 768 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00969", |
| 769 | "vkCreateImage(): pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_BINDING_BIT, but the " |
| 770 | "VkPhysicalDeviceFeatures::sparseBinding feature is disabled."); |
Petr Kraus | b6f9780 | 2018-03-13 12:31:39 +0100 | [diff] [blame] | 771 | } |
| 772 | |
sfricke-samsung | 8f8cf05 | 2020-07-03 22:44:29 -0700 | [diff] [blame] | 773 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_ALIASED_BIT) && (!physical_device_features.sparseResidencyAliased)) { |
| 774 | skip |= LogError( |
| 775 | device, "VUID-VkImageCreateInfo-flags-01924", |
| 776 | "vkCreateImage(): the sparseResidencyAliased device feature is disabled: Images cannot be created with the " |
| 777 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT set."); |
| 778 | } |
| 779 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 780 | // If flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain |
| 781 | // VK_IMAGE_CREATE_SPARSE_BINDING_BIT |
| 782 | if (((pCreateInfo->flags & (VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT | VK_IMAGE_CREATE_SPARSE_ALIASED_BIT)) != 0) && |
| 783 | ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_BINDING_BIT) != VK_IMAGE_CREATE_SPARSE_BINDING_BIT)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 784 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-00987", |
| 785 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT or " |
| 786 | "VK_IMAGE_CREATE_SPARSE_ALIASED_BIT, it must also contain VK_IMAGE_CREATE_SPARSE_BINDING_BIT."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 787 | } |
| 788 | |
| 789 | // Check for combinations of attributes that are incompatible with having VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT set |
| 790 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT) != 0) { |
| 791 | // Linear tiling is unsupported |
| 792 | if (VK_IMAGE_TILING_LINEAR == pCreateInfo->tiling) { |
sfricke-samsung | 9801d75 | 2020-08-23 22:00:16 -0700 | [diff] [blame] | 793 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-04121", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 794 | "vkCreateImage: if pCreateInfo->flags contains VK_IMAGE_CREATE_SPARSE_RESIDENCY_BIT then image " |
| 795 | "tiling of VK_IMAGE_TILING_LINEAR is not supported"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 796 | } |
| 797 | |
| 798 | // Sparse 1D image isn't valid |
| 799 | if (VK_IMAGE_TYPE_1D == pCreateInfo->imageType) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 800 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00970", |
| 801 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 1D image."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 802 | } |
| 803 | |
| 804 | // Sparse 2D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 805 | if ((VK_FALSE == physical_device_features.sparseResidencyImage2D) && (VK_IMAGE_TYPE_2D == pCreateInfo->imageType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 806 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00971", |
| 807 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2D image if corresponding " |
| 808 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 809 | } |
| 810 | |
| 811 | // Sparse 3D image when device doesn't support it |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 812 | if ((VK_FALSE == physical_device_features.sparseResidencyImage3D) && (VK_IMAGE_TYPE_3D == pCreateInfo->imageType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 813 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00972", |
| 814 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 3D image if corresponding " |
| 815 | "feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 816 | } |
| 817 | |
| 818 | // Multi-sample 2D image when device doesn't support it |
| 819 | if (VK_IMAGE_TYPE_2D == pCreateInfo->imageType) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 820 | if ((VK_FALSE == physical_device_features.sparseResidency2Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 821 | (VK_SAMPLE_COUNT_2_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 822 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00973", |
| 823 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 2-sample image if " |
| 824 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 825 | } else if ((VK_FALSE == physical_device_features.sparseResidency4Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 826 | (VK_SAMPLE_COUNT_4_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 827 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00974", |
| 828 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 4-sample image if " |
| 829 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 830 | } else if ((VK_FALSE == physical_device_features.sparseResidency8Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 831 | (VK_SAMPLE_COUNT_8_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 832 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00975", |
| 833 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 8-sample image if " |
| 834 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 835 | } else if ((VK_FALSE == physical_device_features.sparseResidency16Samples) && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 836 | (VK_SAMPLE_COUNT_16_BIT == pCreateInfo->samples)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 837 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-00976", |
| 838 | "vkCreateImage: cannot specify VK_IMAGE_CREATE_SPARSE_BINDING_BIT for 16-sample image if " |
| 839 | "corresponding feature is not enabled on the device."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 840 | } |
| 841 | } |
| 842 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 843 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 844 | if (pCreateInfo->usage & VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV) { |
| 845 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 846 | skip |= LogError(device, "VUID-VkImageCreateInfo-imageType-02082", |
| 847 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 848 | "imageType must be VK_IMAGE_TYPE_2D."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 849 | } |
| 850 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 851 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02083", |
| 852 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 853 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 854 | } |
| 855 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 856 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02084", |
| 857 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_SHADING_RATE_IMAGE_BIT_NV, " |
| 858 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 859 | } |
| 860 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 861 | |
| 862 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 863 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D && pCreateInfo->imageType != VK_IMAGE_TYPE_3D) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 864 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02050", |
| 865 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 866 | "imageType must be VK_IMAGE_TYPE_2D or VK_IMAGE_TYPE_3D."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 867 | } |
| 868 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 869 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || FormatIsDepthOrStencil(pCreateInfo->format)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 870 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02051", |
| 871 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV, " |
| 872 | "it must not also contain VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT and format must " |
| 873 | "not be a depth/stencil format."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 874 | } |
| 875 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 876 | if (pCreateInfo->imageType == VK_IMAGE_TYPE_2D && (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 877 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02052", |
| 878 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 879 | "imageType is VK_IMAGE_TYPE_2D, extent.width and extent.height must be " |
| 880 | "greater than 1."); |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 881 | } else if (pCreateInfo->imageType == VK_IMAGE_TYPE_3D && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 882 | (pCreateInfo->extent.width == 1 || pCreateInfo->extent.height == 1 || pCreateInfo->extent.depth == 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 883 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02053", |
| 884 | "vkCreateImage: If flags contains VK_IMAGE_CREATE_CORNER_SAMPLED_BIT_NV and " |
| 885 | "imageType is VK_IMAGE_TYPE_3D, extent.width, extent.height, and extent.depth " |
| 886 | "must be greater than 1."); |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 887 | } |
| 888 | } |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 889 | |
sfricke-samsung | 8f658d4 | 2020-05-03 20:12:24 -0700 | [diff] [blame] | 890 | if (((pCreateInfo->flags & VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT) != 0) && |
| 891 | (FormatHasDepth(pCreateInfo->format) == false)) { |
| 892 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-01533", |
| 893 | "vkCreateImage(): if flags contain VK_IMAGE_CREATE_SAMPLE_LOCATIONS_COMPATIBLE_DEPTH_BIT_EXT the " |
| 894 | "format must be a depth or depth/stencil format."); |
| 895 | } |
| 896 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 897 | const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfo>(pCreateInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 898 | if (image_stencil_struct != nullptr) { |
| 899 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 900 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 901 | // No flags other than the legal attachment bits may be set |
| 902 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 903 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 904 | skip |= LogError(device, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 905 | "vkCreateImage(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage includes " |
| 906 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 907 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 908 | } |
| 909 | } |
| 910 | |
| 911 | if (FormatIsDepthOrStencil(pCreateInfo->format)) { |
| 912 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT) != 0) { |
| 913 | if (pCreateInfo->extent.width > device_limits.maxFramebufferWidth) { |
| 914 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 915 | LogError(device, "VUID-VkImageCreateInfo-Format-02536", |
| 916 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 917 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image width exceeds device " |
| 918 | "maxFramebufferWidth"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 919 | } |
| 920 | |
| 921 | if (pCreateInfo->extent.height > device_limits.maxFramebufferHeight) { |
| 922 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 923 | LogError(device, "VUID-VkImageCreateInfo-format-02537", |
| 924 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 925 | "stencilUsage including VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT and image height exceeds device " |
| 926 | "maxFramebufferHeight"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 927 | } |
| 928 | } |
| 929 | |
| 930 | if (!physical_device_features.shaderStorageImageMultisample && |
| 931 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 932 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 933 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 934 | LogError(device, "VUID-VkImageCreateInfo-format-02538", |
| 935 | "vkCreateImage(): Depth-stencil image contains VkImageStencilUsageCreateInfo structure with " |
| 936 | "stencilUsage including VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images feature is " |
| 937 | "not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 938 | } |
| 939 | |
| 940 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0) && |
| 941 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 942 | skip |= LogError( |
| 943 | device, "VUID-VkImageCreateInfo-format-02795", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 944 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 945 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 946 | "also include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 947 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) == 0) && |
| 948 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 949 | skip |= LogError( |
| 950 | device, "VUID-VkImageCreateInfo-format-02796", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 951 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 952 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT " |
| 953 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 954 | "also not include VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT"); |
| 955 | } |
| 956 | |
| 957 | if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) && |
| 958 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 959 | skip |= LogError( |
| 960 | device, "VUID-VkImageCreateInfo-format-02797", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 961 | "vkCreateImage(): Depth-stencil image in which usage includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 962 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 963 | "also include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 964 | } else if (((pCreateInfo->usage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) == 0) && |
| 965 | ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 966 | skip |= LogError( |
| 967 | device, "VUID-VkImageCreateInfo-format-02798", |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 968 | "vkCreateImage(): Depth-stencil image in which usage does not include " |
| 969 | "VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT " |
| 970 | "contains VkImageStencilUsageCreateInfo structure, VkImageStencilUsageCreateInfo::stencilUsage must " |
| 971 | "also not include VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT"); |
| 972 | } |
| 973 | } |
| 974 | } |
Spencer Fricke | ca52b5c | 2020-03-16 17:34:00 -0700 | [diff] [blame] | 975 | |
| 976 | if ((!physical_device_features.shaderStorageImageMultisample) && ((pCreateInfo->usage & VK_IMAGE_USAGE_STORAGE_BIT) != 0) && |
| 977 | (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT)) { |
| 978 | skip |= LogError(device, "VUID-VkImageCreateInfo-usage-00968", |
| 979 | "vkCreateImage(): usage contains VK_IMAGE_USAGE_STORAGE_BIT and the multisampled storage images " |
| 980 | "feature is not enabled, image samples must be VK_SAMPLE_COUNT_1_BIT"); |
| 981 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 982 | |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 983 | std::vector<uint64_t> image_create_drm_format_modifiers; |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 984 | if (device_extensions.vk_ext_image_drm_format_modifier) { |
| 985 | const auto drm_format_mod_list = lvl_find_in_chain<VkImageDrmFormatModifierListCreateInfoEXT>(pCreateInfo->pNext); |
| 986 | const auto drm_format_mod_explict = |
| 987 | lvl_find_in_chain<VkImageDrmFormatModifierExplicitCreateInfoEXT>(pCreateInfo->pNext); |
| 988 | if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 989 | if (((drm_format_mod_list != nullptr) && (drm_format_mod_explict != nullptr)) || |
| 990 | ((drm_format_mod_list == nullptr) && (drm_format_mod_explict == nullptr))) { |
| 991 | skip |= LogError(device, "VUID-VkImageCreateInfo-tiling-02261", |
| 992 | "vkCreateImage(): Tiling is VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but pNext must have " |
| 993 | "either VkImageDrmFormatModifierListCreateInfoEXT or " |
| 994 | "VkImageDrmFormatModifierExplicitCreateInfoEXT in the pNext chain"); |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 995 | } else if (drm_format_mod_list != nullptr) { |
| 996 | image_create_drm_format_modifiers.push_back(drm_format_mod_explict->drmFormatModifier); |
| 997 | } else if (drm_format_mod_list != nullptr) { |
| 998 | for (uint32_t i = 0; i < drm_format_mod_list->drmFormatModifierCount; i++) { |
| 999 | image_create_drm_format_modifiers.push_back(*drm_format_mod_list->pDrmFormatModifiers); |
| 1000 | } |
Spencer Fricke | 6f8b8ac | 2020-04-06 07:36:50 -0700 | [diff] [blame] | 1001 | } |
| 1002 | } else if ((drm_format_mod_list != nullptr) || (drm_format_mod_explict != nullptr)) { |
| 1003 | skip |= LogError(device, "VUID-VkImageCreateInfo-pNext-02262", |
| 1004 | "vkCreateImage(): Tiling is not VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT but there is a " |
| 1005 | "VkImageDrmFormatModifierListCreateInfoEXT or VkImageDrmFormatModifierExplicitCreateInfoEXT " |
| 1006 | "in the pNext chain"); |
| 1007 | } |
| 1008 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1009 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1010 | static const uint64_t drm_format_mod_linear = 0; |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1011 | bool image_create_maybe_linear = false; |
| 1012 | if (pCreateInfo->tiling == VK_IMAGE_TILING_LINEAR) { |
| 1013 | image_create_maybe_linear = true; |
| 1014 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_OPTIMAL) { |
| 1015 | image_create_maybe_linear = false; |
| 1016 | } else if (pCreateInfo->tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 1017 | image_create_maybe_linear = |
| 1018 | (std::find(image_create_drm_format_modifiers.begin(), image_create_drm_format_modifiers.end(), |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1019 | drm_format_mod_linear) != image_create_drm_format_modifiers.end()); |
Mark Lobodzinski | 09b4caa | 2020-11-20 17:26:46 -0700 | [diff] [blame] | 1020 | } |
| 1021 | |
| 1022 | // If multi-sample, validate type, usage, tiling and mip levels. |
| 1023 | if ((pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) && |
| 1024 | ((pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) || |
| 1025 | (pCreateInfo->mipLevels != 1) || image_create_maybe_linear)) { |
| 1026 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02257", |
| 1027 | "vkCreateImage(): Multi-sample image with incompatible type, usage, tiling, or mips."); |
| 1028 | } |
| 1029 | |
| 1030 | if ((pCreateInfo->flags & VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT) && |
| 1031 | ((pCreateInfo->mipLevels != 1) || (pCreateInfo->arrayLayers != 1) || (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) || |
| 1032 | image_create_maybe_linear)) { |
| 1033 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02259", |
| 1034 | "vkCreateImage(): Multi-device image with incompatible type, usage, tiling, or mips."); |
| 1035 | } |
| 1036 | |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1037 | if (pCreateInfo->usage & VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT) { |
| 1038 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1039 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02557", |
| 1040 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1041 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1042 | } |
| 1043 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1044 | skip |= LogError(device, "VUID-VkImageCreateInfo-samples-02558", |
| 1045 | "vkCreateImage: if usage includes VK_IMAGE_USAGE_FRAGMENT_DENSITY_MAP_BIT_EXT, " |
| 1046 | "samples must be VK_SAMPLE_COUNT_1_BIT."); |
| 1047 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 1048 | } |
| 1049 | if (pCreateInfo->flags & VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT) { |
| 1050 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1051 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02565", |
| 1052 | "vkCreateImage: if usage includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1053 | "tiling must be VK_IMAGE_TILING_OPTIMAL."); |
| 1054 | } |
| 1055 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1056 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02566", |
| 1057 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1058 | "imageType must be VK_IMAGE_TYPE_2D."); |
| 1059 | } |
| 1060 | if (pCreateInfo->flags & VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT) { |
| 1061 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02567", |
| 1062 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, " |
| 1063 | "flags must not include VK_IMAGE_CREATE_CUBE_COMPATIBLE_BIT."); |
| 1064 | } |
| 1065 | if (pCreateInfo->mipLevels != 1) { |
| 1066 | skip |= LogError(device, "VUID-VkImageCreateInfo-flags-02568", |
| 1067 | "vkCreateImage: if flags includes VK_IMAGE_CREATE_SUBSAMPLED_BIT_EXT, mipLevels (%d) must be 1.", |
| 1068 | pCreateInfo->mipLevels); |
| 1069 | } |
| 1070 | } |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1071 | |
| 1072 | const auto swapchain_create_info = lvl_find_in_chain<VkImageSwapchainCreateInfoKHR>(pCreateInfo->pNext); |
| 1073 | if (swapchain_create_info != nullptr) { |
| 1074 | if (swapchain_create_info->swapchain != VK_NULL_HANDLE) { |
| 1075 | // All the following fall under the same VU that checks that the swapchain image uses parameters limited by the |
| 1076 | // table in #swapchain-wsi-image-create-info. Breaking up into multiple checks allows for more useful information |
| 1077 | // returned why this error occured. Check for matching Swapchain flags is done later in state tracking validation |
| 1078 | const char *vuid = "VUID-VkImageSwapchainCreateInfoKHR-swapchain-00995"; |
| 1079 | const char *base_message = "vkCreateImage(): The image used for creating a presentable swapchain image"; |
| 1080 | |
| 1081 | if (pCreateInfo->imageType != VK_IMAGE_TYPE_2D) { |
| 1082 | // also implicitly forces the check above that extent.depth is 1 |
| 1083 | skip |= LogError(device, vuid, "%s must have a imageType value VK_IMAGE_TYPE_2D instead of %s.", base_message, |
| 1084 | string_VkImageType(pCreateInfo->imageType)); |
| 1085 | } |
| 1086 | if (pCreateInfo->mipLevels != 1) { |
| 1087 | skip |= LogError(device, vuid, "%s must have a mipLevels value of 1 instead of %u.", base_message, |
| 1088 | pCreateInfo->mipLevels); |
| 1089 | } |
| 1090 | if (pCreateInfo->samples != VK_SAMPLE_COUNT_1_BIT) { |
| 1091 | skip |= LogError(device, vuid, "%s must have a samples value of VK_SAMPLE_COUNT_1_BIT instead of %s.", |
| 1092 | base_message, string_VkSampleCountFlagBits(pCreateInfo->samples)); |
| 1093 | } |
| 1094 | if (pCreateInfo->tiling != VK_IMAGE_TILING_OPTIMAL) { |
| 1095 | skip |= LogError(device, vuid, "%s must have a tiling value of VK_IMAGE_TILING_OPTIMAL instead of %s.", |
| 1096 | base_message, string_VkImageTiling(pCreateInfo->tiling)); |
| 1097 | } |
| 1098 | if (pCreateInfo->initialLayout != VK_IMAGE_LAYOUT_UNDEFINED) { |
| 1099 | skip |= LogError(device, vuid, "%s must have a initialLayout value of VK_IMAGE_LAYOUT_UNDEFINED instead of %s.", |
| 1100 | base_message, string_VkImageLayout(pCreateInfo->initialLayout)); |
| 1101 | } |
| 1102 | const VkImageCreateFlags valid_flags = |
| 1103 | (VK_IMAGE_CREATE_SPLIT_INSTANCE_BIND_REGIONS_BIT | VK_IMAGE_CREATE_PROTECTED_BIT | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 1104 | VK_IMAGE_CREATE_MUTABLE_FORMAT_BIT | VK_IMAGE_CREATE_EXTENDED_USAGE_BIT); |
sfricke-samsung | ddaf72b | 2020-06-23 21:39:28 -0700 | [diff] [blame] | 1105 | if ((pCreateInfo->flags & ~valid_flags) != 0) { |
| 1106 | skip |= LogError(device, vuid, "%s flags are %" PRIu32 "and must only have valid flags set.", base_message, |
| 1107 | pCreateInfo->flags); |
| 1108 | } |
| 1109 | } |
| 1110 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1111 | } |
Jeff Bolz | ef40fec | 2018-09-01 22:04:34 -0500 | [diff] [blame] | 1112 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1113 | return skip; |
| 1114 | } |
| 1115 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1116 | bool StatelessValidation::manual_PreCallValidateCreateImageView(VkDevice device, const VkImageViewCreateInfo *pCreateInfo, |
| 1117 | const VkAllocationCallbacks *pAllocator, VkImageView *pView) const { |
| 1118 | bool skip = false; |
| 1119 | |
| 1120 | if (pCreateInfo != nullptr) { |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1121 | // Validate feature set if using CUBE_ARRAY |
| 1122 | if ((pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY) && (physical_device_features.imageCubeArray == false)) { |
| 1123 | skip |= LogError(pCreateInfo->image, "VUID-VkImageViewCreateInfo-viewType-01004", |
| 1124 | "vkCreateImageView(): pCreateInfo->viewType can't be VK_IMAGE_VIEW_TYPE_CUBE_ARRAY without " |
| 1125 | "enabling the imageCubeArray feature."); |
| 1126 | } |
| 1127 | |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1128 | if (pCreateInfo->subresourceRange.layerCount != VK_REMAINING_ARRAY_LAYERS) { |
| 1129 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE && pCreateInfo->subresourceRange.layerCount != 6) { |
| 1130 | skip |= LogError(device, "VUID-VkImageViewCreateInfo-viewType-02960", |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1131 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be 6 or VK_REMAINING_ARRAY_LAYERS.", |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1132 | pCreateInfo->subresourceRange.layerCount); |
| 1133 | } |
| 1134 | if (pCreateInfo->viewType == VK_IMAGE_VIEW_TYPE_CUBE_ARRAY && (pCreateInfo->subresourceRange.layerCount % 6) != 0) { |
Spencer Fricke | 528e098 | 2020-04-19 18:46:01 -0700 | [diff] [blame] | 1135 | skip |= LogError( |
| 1136 | device, "VUID-VkImageViewCreateInfo-viewType-02961", |
| 1137 | "vkCreateImageView(): subresourceRange.layerCount (%d) must be a multiple of 6 or VK_REMAINING_ARRAY_LAYERS.", |
| 1138 | pCreateInfo->subresourceRange.layerCount); |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1139 | } |
| 1140 | } |
sfricke-samsung | 0c4a06f | 2020-06-27 01:24:32 -0700 | [diff] [blame] | 1141 | |
| 1142 | auto astc_decode_mode = lvl_find_in_chain<VkImageViewASTCDecodeModeEXT>(pCreateInfo->pNext); |
| 1143 | if ((device_extensions.vk_ext_astc_decode_mode) && (astc_decode_mode != nullptr)) { |
| 1144 | if ((astc_decode_mode->decodeMode != VK_FORMAT_R16G16B16A16_SFLOAT) && |
| 1145 | (astc_decode_mode->decodeMode != VK_FORMAT_R8G8B8A8_UNORM) && |
| 1146 | (astc_decode_mode->decodeMode != VK_FORMAT_E5B9G9R9_UFLOAT_PACK32)) { |
| 1147 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-decodeMode-02230", |
| 1148 | "vkCreateImageView(): VkImageViewASTCDecodeModeEXT::decodeMode must be " |
| 1149 | "VK_FORMAT_R16G16B16A16_SFLOAT, VK_FORMAT_R8G8B8A8_UNORM, or VK_FORMAT_E5B9G9R9_UFLOAT_PACK32."); |
| 1150 | } |
| 1151 | if (FormatIsCompressed_ASTC(pCreateInfo->format) == false) { |
| 1152 | skip |= LogError(device, "VUID-VkImageViewASTCDecodeModeEXT-format-04084", |
| 1153 | "vkCreateImageView(): is using a VkImageViewASTCDecodeModeEXT but the image view format is %s and " |
| 1154 | "not an ASTC format.", |
| 1155 | string_VkFormat(pCreateInfo->format)); |
| 1156 | } |
| 1157 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 1158 | |
| 1159 | auto ycbcr_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
| 1160 | if (ycbcr_conversion != nullptr) { |
| 1161 | if (ycbcr_conversion->conversion != VK_NULL_HANDLE) { |
| 1162 | if (IsIdentitySwizzle(pCreateInfo->components) == false) { |
| 1163 | skip |= LogError( |
| 1164 | device, "VUID-VkImageViewCreateInfo-pNext-01970", |
| 1165 | "vkCreateImageView(): If there is a VkSamplerYcbcrConversion, the imageView must " |
| 1166 | "be created with the identity swizzle. Here are the actual swizzle values:\n" |
| 1167 | "r swizzle = %s\n" |
| 1168 | "g swizzle = %s\n" |
| 1169 | "b swizzle = %s\n" |
| 1170 | "a swizzle = %s\n", |
| 1171 | string_VkComponentSwizzle(pCreateInfo->components.r), string_VkComponentSwizzle(pCreateInfo->components.g), |
| 1172 | string_VkComponentSwizzle(pCreateInfo->components.b), string_VkComponentSwizzle(pCreateInfo->components.a)); |
| 1173 | } |
| 1174 | } |
| 1175 | } |
Jeff Bolz | 99e3f63 | 2020-03-24 22:59:22 -0500 | [diff] [blame] | 1176 | } |
| 1177 | return skip; |
| 1178 | } |
| 1179 | |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1180 | bool StatelessValidation::manual_PreCallValidateViewport(const VkViewport &viewport, const char *fn_name, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1181 | const ParameterName ¶meter_name, VkCommandBuffer object) const { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1182 | bool skip = false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1183 | |
| 1184 | // Note: for numerical correctness |
| 1185 | // - float comparisons should expect NaN (comparison always false). |
| 1186 | // - VkPhysicalDeviceLimits::maxViewportDimensions is uint32_t, not float -> careful. |
| 1187 | |
| 1188 | const auto f_lte_u32_exact = [](const float v1_f, const uint32_t v2_u32) { |
John Zulauf | ac0876c | 2018-02-19 10:09:35 -0700 | [diff] [blame] | 1189 | if (std::isnan(v1_f)) return false; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1190 | if (v1_f <= 0.0f) return true; |
| 1191 | |
| 1192 | float intpart; |
| 1193 | const float fract = modff(v1_f, &intpart); |
| 1194 | |
| 1195 | assert(std::numeric_limits<float>::radix == 2); |
| 1196 | const float u32_max_plus1 = ldexpf(1.0f, 32); // hopefully exact |
| 1197 | if (intpart >= u32_max_plus1) return false; |
| 1198 | |
| 1199 | uint32_t v1_u32 = static_cast<uint32_t>(intpart); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1200 | if (v1_u32 < v2_u32) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1201 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1202 | } else if (v1_u32 == v2_u32 && fract == 0.0f) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1203 | return true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1204 | } else { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1205 | return false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1206 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1207 | }; |
| 1208 | |
| 1209 | const auto f_lte_u32_direct = [](const float v1_f, const uint32_t v2_u32) { |
| 1210 | const float v2_f = static_cast<float>(v2_u32); // not accurate for > radix^digits; and undefined rounding mode |
| 1211 | return (v1_f <= v2_f); |
| 1212 | }; |
| 1213 | |
| 1214 | // width |
| 1215 | bool width_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1216 | const auto max_w = device_limits.maxViewportDimensions[0]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1217 | |
| 1218 | if (!(viewport.width > 0.0f)) { |
| 1219 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1220 | skip |= LogError(object, "VUID-VkViewport-width-01770", "%s: %s.width (=%f) is not greater than 0.0.", fn_name, |
| 1221 | parameter_name.get_name().c_str(), viewport.width); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1222 | } else if (!(f_lte_u32_exact(viewport.width, max_w) || f_lte_u32_direct(viewport.width, max_w))) { |
| 1223 | width_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1224 | skip |= LogError(object, "VUID-VkViewport-width-01771", |
| 1225 | "%s: %s.width (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[0] (=%" PRIu32 ").", fn_name, |
| 1226 | parameter_name.get_name().c_str(), viewport.width, max_w); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1227 | } |
| 1228 | |
| 1229 | // height |
| 1230 | bool height_healthy = true; |
Mark Lobodzinski | a09ab94 | 2020-02-20 11:01:59 -0700 | [diff] [blame] | 1231 | const bool negative_height_enabled = device_extensions.vk_khr_maintenance1 || device_extensions.vk_amd_negative_viewport_height; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1232 | const auto max_h = device_limits.maxViewportDimensions[1]; |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1233 | |
| 1234 | if (!negative_height_enabled && !(viewport.height > 0.0f)) { |
| 1235 | height_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1236 | skip |= LogError(object, "VUID-VkViewport-height-01772", "%s: %s.height (=%f) is not greater 0.0.", fn_name, |
| 1237 | parameter_name.get_name().c_str(), viewport.height); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1238 | } else if (!(f_lte_u32_exact(fabsf(viewport.height), max_h) || f_lte_u32_direct(fabsf(viewport.height), max_h))) { |
| 1239 | height_healthy = false; |
| 1240 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1241 | skip |= LogError(object, "VUID-VkViewport-height-01773", |
| 1242 | "%s: Absolute value of %s.height (=%f) exceeds VkPhysicalDeviceLimits::maxViewportDimensions[1] (=%" PRIu32 |
| 1243 | ").", |
| 1244 | fn_name, parameter_name.get_name().c_str(), viewport.height, max_h); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1245 | } |
| 1246 | |
| 1247 | // x |
| 1248 | bool x_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1249 | if (!(viewport.x >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1250 | x_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1251 | skip |= LogError(object, "VUID-VkViewport-x-01774", |
| 1252 | "%s: %s.x (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1253 | parameter_name.get_name().c_str(), viewport.x, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1254 | } |
| 1255 | |
| 1256 | // x + width |
| 1257 | if (x_healthy && width_healthy) { |
| 1258 | const float right_bound = viewport.x + viewport.width; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1259 | if (!(right_bound <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1260 | skip |= LogError( |
| 1261 | object, "VUID-VkViewport-x-01232", |
| 1262 | "%s: %s.x + %s.width (=%f + %f = %f) is greater than VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1263 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.x, viewport.width, |
| 1264 | right_bound, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1265 | } |
| 1266 | } |
| 1267 | |
| 1268 | // y |
| 1269 | bool y_healthy = true; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1270 | if (!(viewport.y >= device_limits.viewportBoundsRange[0])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1271 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1272 | skip |= LogError(object, "VUID-VkViewport-y-01775", |
| 1273 | "%s: %s.y (=%f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", fn_name, |
| 1274 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[0]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1275 | } else if (negative_height_enabled && !(viewport.y <= device_limits.viewportBoundsRange[1])) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1276 | y_healthy = false; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1277 | skip |= LogError(object, "VUID-VkViewport-y-01776", |
| 1278 | "%s: %s.y (=%f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", fn_name, |
| 1279 | parameter_name.get_name().c_str(), viewport.y, device_limits.viewportBoundsRange[1]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1280 | } |
| 1281 | |
| 1282 | // y + height |
| 1283 | if (y_healthy && height_healthy) { |
| 1284 | const float boundary = viewport.y + viewport.height; |
| 1285 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1286 | if (!(boundary <= device_limits.viewportBoundsRange[1])) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1287 | skip |= LogError(object, "VUID-VkViewport-y-01233", |
| 1288 | "%s: %s.y + %s.height (=%f + %f = %f) exceeds VkPhysicalDeviceLimits::viewportBoundsRange[1] (=%f).", |
| 1289 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, |
| 1290 | viewport.height, boundary, device_limits.viewportBoundsRange[1]); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1291 | } else if (negative_height_enabled && !(boundary >= device_limits.viewportBoundsRange[0])) { |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 1292 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1293 | LogError(object, "VUID-VkViewport-y-01777", |
| 1294 | "%s: %s.y + %s.height (=%f + %f = %f) is less than VkPhysicalDeviceLimits::viewportBoundsRange[0] (=%f).", |
| 1295 | fn_name, parameter_name.get_name().c_str(), parameter_name.get_name().c_str(), viewport.y, viewport.height, |
| 1296 | boundary, device_limits.viewportBoundsRange[0]); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1297 | } |
| 1298 | } |
| 1299 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1300 | if (!device_extensions.vk_ext_depth_range_unrestricted) { |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1301 | // minDepth |
| 1302 | if (!(viewport.minDepth >= 0.0) || !(viewport.minDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1303 | skip |= LogError(object, "VUID-VkViewport-minDepth-01234", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1304 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1305 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.minDepth (=%f) is not within the " |
| 1306 | "[0.0, 1.0] range.", |
| 1307 | fn_name, parameter_name.get_name().c_str(), viewport.minDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1308 | } |
| 1309 | |
| 1310 | // maxDepth |
| 1311 | if (!(viewport.maxDepth >= 0.0) || !(viewport.maxDepth <= 1.0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1312 | skip |= LogError(object, "VUID-VkViewport-maxDepth-01235", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 1313 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1314 | "%s: VK_EXT_depth_range_unrestricted extension is not enabled and %s.maxDepth (=%f) is not within the " |
| 1315 | "[0.0, 1.0] range.", |
| 1316 | fn_name, parameter_name.get_name().c_str(), viewport.maxDepth); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 1317 | } |
| 1318 | } |
| 1319 | |
| 1320 | return skip; |
| 1321 | } |
| 1322 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1323 | struct SampleOrderInfo { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1324 | VkShadingRatePaletteEntryNV shadingRate; |
| 1325 | uint32_t width; |
| 1326 | uint32_t height; |
| 1327 | }; |
| 1328 | |
| 1329 | // All palette entries with more than one pixel per fragment |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1330 | static SampleOrderInfo sample_order_infos[] = { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1331 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_1X2_PIXELS_NV, 1, 2}, |
| 1332 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X1_PIXELS_NV, 2, 1}, |
| 1333 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X2_PIXELS_NV, 2, 2}, |
| 1334 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X2_PIXELS_NV, 4, 2}, |
| 1335 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_2X4_PIXELS_NV, 2, 4}, |
| 1336 | {VK_SHADING_RATE_PALETTE_ENTRY_1_INVOCATION_PER_4X4_PIXELS_NV, 4, 4}, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1337 | }; |
| 1338 | |
Jeff Bolz | 46c0ea0 | 2019-10-09 13:06:29 -0500 | [diff] [blame] | 1339 | bool StatelessValidation::ValidateCoarseSampleOrderCustomNV(const VkCoarseSampleOrderCustomNV *order) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1340 | bool skip = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1341 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1342 | SampleOrderInfo *sample_order_info; |
| 1343 | uint32_t info_idx = 0; |
| 1344 | for (sample_order_info = nullptr; info_idx < ARRAY_SIZE(sample_order_infos); ++info_idx) { |
| 1345 | if (sample_order_infos[info_idx].shadingRate == order->shadingRate) { |
| 1346 | sample_order_info = &sample_order_infos[info_idx]; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1347 | break; |
| 1348 | } |
| 1349 | } |
| 1350 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1351 | if (sample_order_info == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1352 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-shadingRate-02073", |
| 1353 | "VkCoarseSampleOrderCustomNV shadingRate must be a shading rate " |
| 1354 | "that generates fragments with more than one pixel."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1355 | return skip; |
| 1356 | } |
| 1357 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1358 | if (order->sampleCount == 0 || (order->sampleCount & (order->sampleCount - 1)) || |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1359 | !(order->sampleCount & device_limits.framebufferNoAttachmentsSampleCounts)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1360 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleCount-02074", |
| 1361 | "VkCoarseSampleOrderCustomNV sampleCount (=%" PRIu32 |
| 1362 | ") must " |
| 1363 | "correspond to a sample count enumerated in VkSampleCountFlags whose corresponding bit " |
| 1364 | "is set in framebufferNoAttachmentsSampleCounts.", |
| 1365 | order->sampleCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1366 | } |
| 1367 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1368 | if (order->sampleLocationCount != order->sampleCount * sample_order_info->width * sample_order_info->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1369 | skip |= LogError(device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02075", |
| 1370 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1371 | ") must " |
| 1372 | "be equal to the product of sampleCount (=%" PRIu32 |
| 1373 | "), the fragment width for shadingRate " |
| 1374 | "(=%" PRIu32 "), and the fragment height for shadingRate (=%" PRIu32 ").", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1375 | order->sampleLocationCount, order->sampleCount, sample_order_info->width, sample_order_info->height); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1376 | } |
| 1377 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1378 | if (order->sampleLocationCount > phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1379 | skip |= LogError( |
| 1380 | device, "VUID-VkCoarseSampleOrderCustomNV-sampleLocationCount-02076", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1381 | "VkCoarseSampleOrderCustomNV sampleLocationCount (=%" PRIu32 |
| 1382 | ") must " |
| 1383 | "be less than or equal to VkPhysicalDeviceShadingRateImagePropertiesNV shadingRateMaxCoarseSamples (=%" PRIu32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1384 | order->sampleLocationCount, phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1385 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1386 | |
| 1387 | // Accumulate a bitmask tracking which (x,y,sample) tuples are seen. Expect |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 1388 | // the first width*height*sampleCount bits to all be set. Note: There is no |
| 1389 | // guarantee that 64 bits is enough, but practically it's unlikely for an |
| 1390 | // implementation to support more than 32 bits for samplemask. |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1391 | assert(phys_dev_ext_props.shading_rate_image_props.shadingRateMaxCoarseSamples <= 64); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1392 | uint64_t sample_locations_mask = 0; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1393 | for (uint32_t i = 0; i < order->sampleLocationCount; ++i) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1394 | const VkCoarseSampleLocationNV *sample_loc = &order->pSampleLocations[i]; |
| 1395 | if (sample_loc->pixelX >= sample_order_info->width) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1396 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelX-02078", |
| 1397 | "pixelX must be less than the width (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1398 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1399 | if (sample_loc->pixelY >= sample_order_info->height) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1400 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-pixelY-02079", |
| 1401 | "pixelY must be less than the height (in pixels) of the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1402 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1403 | if (sample_loc->sample >= order->sampleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1404 | skip |= LogError(device, "VUID-VkCoarseSampleLocationNV-sample-02080", |
| 1405 | "sample must be less than the number of coverage samples in each pixel belonging to the fragment."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1406 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1407 | uint32_t idx = |
| 1408 | sample_loc->sample + order->sampleCount * (sample_loc->pixelX + sample_order_info->width * sample_loc->pixelY); |
| 1409 | sample_locations_mask |= 1ULL << idx; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1410 | } |
| 1411 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1412 | uint64_t expected_mask = (order->sampleLocationCount == 64) ? ~0ULL : ((1ULL << order->sampleLocationCount) - 1); |
| 1413 | if (sample_locations_mask != expected_mask) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1414 | skip |= LogError( |
| 1415 | device, "VUID-VkCoarseSampleOrderCustomNV-pSampleLocations-02077", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1416 | "The array pSampleLocations must contain exactly one entry for " |
| 1417 | "every combination of valid values for pixelX, pixelY, and sample in the structure VkCoarseSampleOrderCustomNV."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1418 | } |
| 1419 | |
| 1420 | return skip; |
| 1421 | } |
| 1422 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 1423 | bool StatelessValidation::manual_PreCallValidateCreateGraphicsPipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 1424 | uint32_t createInfoCount, |
| 1425 | const VkGraphicsPipelineCreateInfo *pCreateInfos, |
| 1426 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 1427 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1428 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1429 | |
| 1430 | if (pCreateInfos != nullptr) { |
| 1431 | for (uint32_t i = 0; i < createInfoCount; ++i) { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1432 | bool has_dynamic_viewport = false; |
| 1433 | bool has_dynamic_scissor = false; |
| 1434 | bool has_dynamic_line_width = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1435 | bool has_dynamic_depth_bias = false; |
| 1436 | bool has_dynamic_blend_constant = false; |
| 1437 | bool has_dynamic_depth_bounds = false; |
| 1438 | bool has_dynamic_stencil_compare = false; |
| 1439 | bool has_dynamic_stencil_write = false; |
| 1440 | bool has_dynamic_stencil_reference = false; |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 1441 | bool has_dynamic_viewport_w_scaling_nv = false; |
| 1442 | bool has_dynamic_discard_rectangle_ext = false; |
| 1443 | bool has_dynamic_sample_locations_ext = false; |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 1444 | bool has_dynamic_exclusive_scissor_nv = false; |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 1445 | bool has_dynamic_shading_rate_palette_nv = false; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1446 | bool has_dynamic_viewport_course_sample_order_nv = false; |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 1447 | bool has_dynamic_line_stipple = false; |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1448 | bool has_dynamic_cull_mode = false; |
| 1449 | bool has_dynamic_front_face = false; |
| 1450 | bool has_dynamic_primitive_topology = false; |
| 1451 | bool has_dynamic_viewport_with_count = false; |
| 1452 | bool has_dynamic_scissor_with_count = false; |
| 1453 | bool has_dynamic_vertex_input_binding_stride = false; |
| 1454 | bool has_dynamic_depth_test_enable = false; |
| 1455 | bool has_dynamic_depth_write_enable = false; |
| 1456 | bool has_dynamic_depth_compare_op = false; |
| 1457 | bool has_dynamic_depth_bounds_test_enable = false; |
| 1458 | bool has_dynamic_stencil_test_enable = false; |
| 1459 | bool has_dynamic_stencil_op = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 1460 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 1461 | skip |= |
| 1462 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-03377", |
| 1463 | "vkCreateGraphicsPipelines: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR"); |
| 1464 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1465 | if (pCreateInfos[i].pDynamicState != nullptr) { |
| 1466 | const auto &dynamic_state_info = *pCreateInfos[i].pDynamicState; |
| 1467 | for (uint32_t state_index = 0; state_index < dynamic_state_info.dynamicStateCount; ++state_index) { |
| 1468 | const auto &dynamic_state = dynamic_state_info.pDynamicStates[state_index]; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1469 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT) { |
| 1470 | if (has_dynamic_viewport == true) { |
| 1471 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1472 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT was listed twice in the " |
| 1473 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1474 | i); |
| 1475 | } |
| 1476 | has_dynamic_viewport = true; |
| 1477 | } |
| 1478 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR) { |
| 1479 | if (has_dynamic_scissor == true) { |
| 1480 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1481 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR was listed twice in the " |
| 1482 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1483 | i); |
| 1484 | } |
| 1485 | has_dynamic_scissor = true; |
| 1486 | } |
| 1487 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_WIDTH) { |
| 1488 | if (has_dynamic_line_width == true) { |
| 1489 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1490 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_WIDTH was listed twice in the " |
| 1491 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1492 | i); |
| 1493 | } |
| 1494 | has_dynamic_line_width = true; |
| 1495 | } |
| 1496 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BIAS) { |
| 1497 | if (has_dynamic_depth_bias == true) { |
| 1498 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1499 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BIAS was listed twice in the " |
| 1500 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1501 | i); |
| 1502 | } |
| 1503 | has_dynamic_depth_bias = true; |
| 1504 | } |
| 1505 | if (dynamic_state == VK_DYNAMIC_STATE_BLEND_CONSTANTS) { |
| 1506 | if (has_dynamic_blend_constant == true) { |
| 1507 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1508 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_BLEND_CONSTANTS was listed twice in the " |
| 1509 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1510 | i); |
| 1511 | } |
| 1512 | has_dynamic_blend_constant = true; |
| 1513 | } |
| 1514 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS) { |
| 1515 | if (has_dynamic_depth_bounds == true) { |
| 1516 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1517 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS was listed twice in the " |
| 1518 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1519 | i); |
| 1520 | } |
| 1521 | has_dynamic_depth_bounds = true; |
| 1522 | } |
| 1523 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK) { |
| 1524 | if (has_dynamic_stencil_compare == true) { |
| 1525 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1526 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_COMPARE_MASK was listed twice in " |
| 1527 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1528 | i); |
| 1529 | } |
| 1530 | has_dynamic_stencil_compare = true; |
| 1531 | } |
| 1532 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_WRITE_MASK) { |
| 1533 | if (has_dynamic_stencil_write == true) { |
| 1534 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1535 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_WRITE_MASK was listed twice in " |
| 1536 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1537 | i); |
| 1538 | } |
| 1539 | has_dynamic_stencil_write = true; |
| 1540 | } |
| 1541 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_REFERENCE) { |
| 1542 | if (has_dynamic_stencil_reference == true) { |
| 1543 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1544 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_REFERENCE was listed twice in " |
| 1545 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1546 | i); |
| 1547 | } |
| 1548 | has_dynamic_stencil_reference = true; |
| 1549 | } |
| 1550 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV) { |
| 1551 | if (has_dynamic_viewport_w_scaling_nv == true) { |
| 1552 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1553 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV was listed twice " |
| 1554 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1555 | i); |
| 1556 | } |
| 1557 | has_dynamic_viewport_w_scaling_nv = true; |
| 1558 | } |
| 1559 | if (dynamic_state == VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT) { |
| 1560 | if (has_dynamic_discard_rectangle_ext == true) { |
| 1561 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1562 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT was listed twice " |
| 1563 | "in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1564 | i); |
| 1565 | } |
| 1566 | has_dynamic_discard_rectangle_ext = true; |
| 1567 | } |
| 1568 | if (dynamic_state == VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT) { |
| 1569 | if (has_dynamic_sample_locations_ext == true) { |
| 1570 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1571 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT was listed twice in " |
| 1572 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1573 | i); |
| 1574 | } |
| 1575 | has_dynamic_sample_locations_ext = true; |
| 1576 | } |
| 1577 | if (dynamic_state == VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV) { |
| 1578 | if (has_dynamic_exclusive_scissor_nv == true) { |
| 1579 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1580 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV was listed twice in " |
| 1581 | "the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1582 | i); |
| 1583 | } |
| 1584 | has_dynamic_exclusive_scissor_nv = true; |
| 1585 | } |
| 1586 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV) { |
| 1587 | if (has_dynamic_shading_rate_palette_nv == true) { |
| 1588 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1589 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV was " |
| 1590 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1591 | i); |
| 1592 | } |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 1593 | has_dynamic_shading_rate_palette_nv = true; |
Spencer Fricke | 8d42888 | 2020-03-16 17:23:33 -0700 | [diff] [blame] | 1594 | } |
| 1595 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV) { |
| 1596 | if (has_dynamic_viewport_course_sample_order_nv == true) { |
| 1597 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1598 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_COARSE_SAMPLE_ORDER_NV was " |
| 1599 | "listed twice in the pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1600 | i); |
| 1601 | } |
| 1602 | has_dynamic_viewport_course_sample_order_nv = true; |
| 1603 | } |
| 1604 | if (dynamic_state == VK_DYNAMIC_STATE_LINE_STIPPLE_EXT) { |
| 1605 | if (has_dynamic_line_stipple == true) { |
| 1606 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1607 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_LINE_STIPPLE_EXT was listed twice in the " |
| 1608 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1609 | i); |
| 1610 | } |
| 1611 | has_dynamic_line_stipple = true; |
| 1612 | } |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 1613 | if (dynamic_state == VK_DYNAMIC_STATE_CULL_MODE_EXT) { |
| 1614 | if (has_dynamic_cull_mode) { |
| 1615 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1616 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_CULL_MODE_EXT was listed twice in the " |
| 1617 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1618 | i); |
| 1619 | } |
| 1620 | has_dynamic_cull_mode = true; |
| 1621 | } |
| 1622 | if (dynamic_state == VK_DYNAMIC_STATE_FRONT_FACE_EXT) { |
| 1623 | if (has_dynamic_front_face) { |
| 1624 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1625 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_FRONT_FACE_EXT was listed twice in the " |
| 1626 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1627 | i); |
| 1628 | } |
| 1629 | has_dynamic_front_face = true; |
| 1630 | } |
| 1631 | if (dynamic_state == VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT) { |
| 1632 | if (has_dynamic_primitive_topology) { |
| 1633 | skip |= LogError( |
| 1634 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1635 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_PRIMITIVE_TOPOLOGY_EXT was listed twice in the " |
| 1636 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1637 | i); |
| 1638 | } |
| 1639 | has_dynamic_primitive_topology = true; |
| 1640 | } |
| 1641 | if (dynamic_state == VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT) { |
| 1642 | if (has_dynamic_viewport_with_count) { |
| 1643 | skip |= LogError( |
| 1644 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1645 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT was listed twice in the " |
| 1646 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1647 | i); |
| 1648 | } |
| 1649 | has_dynamic_viewport_with_count = true; |
| 1650 | } |
| 1651 | if (dynamic_state == VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT) { |
| 1652 | if (has_dynamic_scissor_with_count) { |
| 1653 | skip |= LogError( |
| 1654 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1655 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT was listed twice in the " |
| 1656 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1657 | i); |
| 1658 | } |
| 1659 | has_dynamic_scissor_with_count = true; |
| 1660 | } |
| 1661 | if (dynamic_state == VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT) { |
| 1662 | if (has_dynamic_vertex_input_binding_stride) { |
| 1663 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1664 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_VERTEX_INPUT_BINDING_STRIDE_EXT was " |
| 1665 | "listed twice in the " |
| 1666 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1667 | i); |
| 1668 | } |
| 1669 | has_dynamic_vertex_input_binding_stride = true; |
| 1670 | } |
| 1671 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT) { |
| 1672 | if (has_dynamic_depth_test_enable) { |
| 1673 | skip |= LogError( |
| 1674 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1675 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_TEST_ENABLE_EXT was listed twice in the " |
| 1676 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1677 | i); |
| 1678 | } |
| 1679 | has_dynamic_depth_test_enable = true; |
| 1680 | } |
| 1681 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT) { |
| 1682 | if (has_dynamic_depth_write_enable) { |
| 1683 | skip |= LogError( |
| 1684 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1685 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_WRITE_ENABLE_EXT was listed twice in the " |
| 1686 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1687 | i); |
| 1688 | } |
| 1689 | has_dynamic_depth_write_enable = true; |
| 1690 | } |
| 1691 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT) { |
| 1692 | if (has_dynamic_depth_compare_op) { |
| 1693 | skip |= |
| 1694 | LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1695 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_COMPARE_OP_EXT was listed twice in the " |
| 1696 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1697 | i); |
| 1698 | } |
| 1699 | has_dynamic_depth_compare_op = true; |
| 1700 | } |
| 1701 | if (dynamic_state == VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT) { |
| 1702 | if (has_dynamic_depth_bounds_test_enable) { |
| 1703 | skip |= LogError( |
| 1704 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1705 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_DEPTH_BOUNDS_TEST_ENABLE_EXT was listed twice in the " |
| 1706 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1707 | i); |
| 1708 | } |
| 1709 | has_dynamic_depth_bounds_test_enable = true; |
| 1710 | } |
| 1711 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT) { |
| 1712 | if (has_dynamic_stencil_test_enable) { |
| 1713 | skip |= LogError( |
| 1714 | device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1715 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_TEST_ENABLE_EXT was listed twice in the " |
| 1716 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1717 | i); |
| 1718 | } |
| 1719 | has_dynamic_stencil_test_enable = true; |
| 1720 | } |
| 1721 | if (dynamic_state == VK_DYNAMIC_STATE_STENCIL_OP_EXT) { |
| 1722 | if (has_dynamic_stencil_op) { |
| 1723 | skip |= LogError(device, "VUID-VkPipelineDynamicStateCreateInfo-pDynamicStates-01442", |
| 1724 | "vkCreateGraphicsPipelines: VK_DYNAMIC_STATE_STENCIL_OP_EXT was listed twice in the " |
| 1725 | "pCreateInfos[%d].pDynamicState->pDynamicStates array", |
| 1726 | i); |
| 1727 | } |
| 1728 | has_dynamic_stencil_op = true; |
| 1729 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 1730 | } |
| 1731 | } |
| 1732 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1733 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 1734 | if ((feedback_struct != nullptr) && |
| 1735 | (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1736 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02668", |
| 1737 | "vkCreateGraphicsPipelines(): in pCreateInfo[%" PRIu32 |
| 1738 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 1739 | "(=%" PRIu32 ") must equal VkGraphicsPipelineCreateInfo::stageCount(=%" PRIu32 ").", |
| 1740 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 1741 | } |
| 1742 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1743 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1744 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1745 | // Collect active stages and other information |
| 1746 | // Only want to loop through pStages once |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1747 | uint32_t active_shaders = 0; |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1748 | bool has_eval = false; |
| 1749 | bool has_control = false; |
| 1750 | if (pCreateInfos[i].pStages != nullptr) { |
| 1751 | for (uint32_t stage_index = 0; stage_index < pCreateInfos[i].stageCount; ++stage_index) { |
| 1752 | active_shaders |= pCreateInfos[i].pStages[stage_index].stage; |
| 1753 | |
| 1754 | if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) { |
| 1755 | has_control = true; |
| 1756 | } else if (pCreateInfos[i].pStages[stage_index].stage == VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) { |
| 1757 | has_eval = true; |
| 1758 | } |
| 1759 | |
| 1760 | skip |= validate_string( |
| 1761 | "vkCreateGraphicsPipelines", |
| 1762 | ParameterName("pCreateInfos[%i].pStages[%i].pName", ParameterName::IndexVector{i, stage_index}), |
| 1763 | "VUID-VkGraphicsPipelineCreateInfo-pStages-parameter", pCreateInfos[i].pStages[stage_index].pName); |
| 1764 | } |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1765 | } |
| 1766 | |
| 1767 | if ((active_shaders & VK_SHADER_STAGE_TESSELLATION_CONTROL_BIT) && |
| 1768 | (active_shaders & VK_SHADER_STAGE_TESSELLATION_EVALUATION_BIT) && (pCreateInfos[i].pTessellationState != nullptr)) { |
| 1769 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState", |
| 1770 | "VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO", |
| 1771 | pCreateInfos[i].pTessellationState, |
| 1772 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1773 | "VUID-VkPipelineTessellationStateCreateInfo-sType-sType"); |
| 1774 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1775 | const VkStructureType allowed_structs_vk_pipeline_tessellation_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1776 | VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO}; |
| 1777 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1778 | skip |= validate_struct_pnext( |
| 1779 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->pNext", |
| 1780 | "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, |
| 1781 | ARRAY_SIZE(allowed_structs_vk_pipeline_tessellation_state_create_info), |
| 1782 | allowed_structs_vk_pipeline_tessellation_state_create_info, GeneratedVulkanHeaderVersion, |
| 1783 | "VUID-VkPipelineTessellationStateCreateInfo-pNext-pNext", |
| 1784 | "VUID-VkPipelineTessellationStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1785 | |
| 1786 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pTessellationState->flags", |
| 1787 | pCreateInfos[i].pTessellationState->flags, |
| 1788 | "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
| 1789 | } |
| 1790 | |
| 1791 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pInputAssemblyState != nullptr)) { |
| 1792 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState", |
| 1793 | "VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO", |
| 1794 | pCreateInfos[i].pInputAssemblyState, |
| 1795 | VK_STRUCTURE_TYPE_PIPELINE_INPUT_ASSEMBLY_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 1796 | "VUID-VkPipelineInputAssemblyStateCreateInfo-sType-sType"); |
| 1797 | |
| 1798 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->pNext", NULL, |
| 1799 | pCreateInfos[i].pInputAssemblyState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1800 | "VUID-VkPipelineInputAssemblyStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1801 | |
| 1802 | skip |= validate_reserved_flags("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->flags", |
| 1803 | pCreateInfos[i].pInputAssemblyState->flags, |
| 1804 | "VUID-VkPipelineInputAssemblyStateCreateInfo-flags-zerobitmask"); |
| 1805 | |
| 1806 | skip |= validate_ranged_enum("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->topology", |
| 1807 | "VkPrimitiveTopology", AllVkPrimitiveTopologyEnums, |
| 1808 | pCreateInfos[i].pInputAssemblyState->topology, |
| 1809 | "VUID-VkPipelineInputAssemblyStateCreateInfo-topology-parameter"); |
| 1810 | |
| 1811 | skip |= validate_bool32("vkCreateGraphicsPipelines", "pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable", |
| 1812 | pCreateInfos[i].pInputAssemblyState->primitiveRestartEnable); |
| 1813 | } |
| 1814 | |
| 1815 | if (!(active_shaders & VK_SHADER_STAGE_MESH_BIT_NV) && (pCreateInfos[i].pVertexInputState != nullptr)) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1816 | auto const &vertex_input_state = pCreateInfos[i].pVertexInputState; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1817 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1818 | if (pCreateInfos[i].pVertexInputState->flags != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1819 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-flags-zerobitmask", |
| 1820 | "vkCreateGraphicsPipelines: pararameter " |
| 1821 | "pCreateInfos[%d].pVertexInputState->flags (%u) is reserved and must be zero.", |
| 1822 | i, vertex_input_state->flags); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1823 | } |
| 1824 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1825 | const VkStructureType allowed_structs_vk_pipeline_vertex_input_state_create_info[] = { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1826 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_DIVISOR_STATE_CREATE_INFO_EXT}; |
| 1827 | skip |= validate_struct_pnext("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->pNext", |
| 1828 | "VkPipelineVertexInputDivisorStateCreateInfoEXT", |
| 1829 | pCreateInfos[i].pVertexInputState->pNext, 1, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1830 | allowed_structs_vk_pipeline_vertex_input_state_create_info, |
| 1831 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineVertexInputStateCreateInfo-pNext-pNext", |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 1832 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-unique"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1833 | skip |= validate_struct_type("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState", |
| 1834 | "VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO", vertex_input_state, |
Shannon McPherson | 3cc90bc | 2019-08-13 11:28:22 -0600 | [diff] [blame] | 1835 | VK_STRUCTURE_TYPE_PIPELINE_VERTEX_INPUT_STATE_CREATE_INFO, false, kVUIDUndefined, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1836 | "VUID-VkPipelineVertexInputStateCreateInfo-sType-sType"); |
| 1837 | skip |= |
| 1838 | validate_array("vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount", |
| 1839 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions", |
| 1840 | pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount, |
| 1841 | &pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions, false, true, kVUIDUndefined, |
| 1842 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-parameter"); |
| 1843 | |
| 1844 | skip |= validate_array( |
| 1845 | "vkCreateGraphicsPipelines", "pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount", |
| 1846 | "pCreateInfos[i]->pVertexAttributeDescriptions", vertex_input_state->vertexAttributeDescriptionCount, |
| 1847 | &vertex_input_state->pVertexAttributeDescriptions, false, true, kVUIDUndefined, |
| 1848 | "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-parameter"); |
| 1849 | |
| 1850 | if (pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1851 | for (uint32_t vertex_binding_description_index = 0; |
| 1852 | vertex_binding_description_index < pCreateInfos[i].pVertexInputState->vertexBindingDescriptionCount; |
| 1853 | ++vertex_binding_description_index) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1854 | skip |= validate_ranged_enum( |
| 1855 | "vkCreateGraphicsPipelines", |
| 1856 | "pCreateInfos[i].pVertexInputState->pVertexBindingDescriptions[j].inputRate", "VkVertexInputRate", |
| 1857 | AllVkVertexInputRateEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1858 | pCreateInfos[i] |
| 1859 | .pVertexInputState->pVertexBindingDescriptions[vertex_binding_description_index] |
| 1860 | .inputRate, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1861 | "VUID-VkVertexInputBindingDescription-inputRate-parameter"); |
| 1862 | } |
| 1863 | } |
| 1864 | |
| 1865 | if (pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1866 | for (uint32_t vertex_attribute_description_index = 0; |
| 1867 | vertex_attribute_description_index < pCreateInfos[i].pVertexInputState->vertexAttributeDescriptionCount; |
| 1868 | ++vertex_attribute_description_index) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1869 | skip |= validate_ranged_enum( |
| 1870 | "vkCreateGraphicsPipelines", |
| 1871 | "pCreateInfos[i].pVertexInputState->pVertexAttributeDescriptions[i].format", "VkFormat", |
| 1872 | AllVkFormatEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 1873 | pCreateInfos[i] |
| 1874 | .pVertexInputState->pVertexAttributeDescriptions[vertex_attribute_description_index] |
| 1875 | .format, |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 1876 | "VUID-VkVertexInputAttributeDescription-format-parameter"); |
| 1877 | } |
| 1878 | } |
| 1879 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1880 | if (vertex_input_state->vertexBindingDescriptionCount > device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1881 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexBindingDescriptionCount-00613", |
| 1882 | "vkCreateGraphicsPipelines: pararameter " |
| 1883 | "pCreateInfo[%d].pVertexInputState->vertexBindingDescriptionCount (%u) is " |
| 1884 | "greater than VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1885 | i, vertex_input_state->vertexBindingDescriptionCount, device_limits.maxVertexInputBindings); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1886 | } |
| 1887 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1888 | if (vertex_input_state->vertexAttributeDescriptionCount > device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1889 | skip |= |
| 1890 | LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-vertexAttributeDescriptionCount-00614", |
| 1891 | "vkCreateGraphicsPipelines: pararameter " |
| 1892 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptionCount (%u) is " |
| 1893 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1894 | i, vertex_input_state->vertexAttributeDescriptionCount, device_limits.maxVertexInputAttributes); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1895 | } |
| 1896 | |
| 1897 | std::unordered_set<uint32_t> vertex_bindings(vertex_input_state->vertexBindingDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1898 | for (uint32_t d = 0; d < vertex_input_state->vertexBindingDescriptionCount; ++d) { |
| 1899 | auto const &vertex_bind_desc = vertex_input_state->pVertexBindingDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1900 | auto const &binding_it = vertex_bindings.find(vertex_bind_desc.binding); |
| 1901 | if (binding_it != vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1902 | skip |= LogError(device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexBindingDescriptions-00616", |
| 1903 | "vkCreateGraphicsPipelines: parameter " |
| 1904 | "pCreateInfo[%d].pVertexInputState->pVertexBindingDescription[%d].binding " |
| 1905 | "(%" PRIu32 ") is not distinct.", |
| 1906 | i, d, vertex_bind_desc.binding); |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1907 | } |
| 1908 | vertex_bindings.insert(vertex_bind_desc.binding); |
| 1909 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1910 | if (vertex_bind_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1911 | skip |= LogError(device, "VUID-VkVertexInputBindingDescription-binding-00618", |
| 1912 | "vkCreateGraphicsPipelines: parameter " |
| 1913 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].binding (%u) is " |
| 1914 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1915 | i, d, vertex_bind_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1916 | } |
| 1917 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1918 | if (vertex_bind_desc.stride > device_limits.maxVertexInputBindingStride) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1919 | skip |= |
| 1920 | LogError(device, "VUID-VkVertexInputBindingDescription-stride-00619", |
| 1921 | "vkCreateGraphicsPipelines: parameter " |
| 1922 | "pCreateInfos[%u].pVertexInputState->pVertexBindingDescriptions[%u].stride (%u) is greater " |
| 1923 | "than VkPhysicalDeviceLimits::maxVertexInputBindingStride (%u).", |
| 1924 | i, d, vertex_bind_desc.stride, device_limits.maxVertexInputBindingStride); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1925 | } |
| 1926 | } |
| 1927 | |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1928 | std::unordered_set<uint32_t> attribute_locations(vertex_input_state->vertexAttributeDescriptionCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1929 | for (uint32_t d = 0; d < vertex_input_state->vertexAttributeDescriptionCount; ++d) { |
| 1930 | auto const &vertex_attrib_desc = vertex_input_state->pVertexAttributeDescriptions[d]; |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1931 | auto const &location_it = attribute_locations.find(vertex_attrib_desc.location); |
| 1932 | if (location_it != attribute_locations.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1933 | skip |= LogError( |
| 1934 | device, "VUID-VkPipelineVertexInputStateCreateInfo-pVertexAttributeDescriptions-00617", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1935 | "vkCreateGraphicsPipelines: parameter " |
| 1936 | "pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].location (%u) is not distinct.", |
| 1937 | i, d, vertex_attrib_desc.location); |
| 1938 | } |
| 1939 | attribute_locations.insert(vertex_attrib_desc.location); |
| 1940 | |
| 1941 | auto const &binding_it = vertex_bindings.find(vertex_attrib_desc.binding); |
| 1942 | if (binding_it == vertex_bindings.cend()) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1943 | skip |= LogError( |
| 1944 | device, "VUID-VkPipelineVertexInputStateCreateInfo-binding-00615", |
Peter Kohaut | c7d9d39 | 2018-07-15 00:34:07 +0200 | [diff] [blame] | 1945 | "vkCreateGraphicsPipelines: parameter " |
| 1946 | " pCreateInfo[%d].pVertexInputState->vertexAttributeDescriptions[%d].binding (%u) does not exist " |
| 1947 | "in any pCreateInfo[%d].pVertexInputState->pVertexBindingDescription.", |
| 1948 | i, d, vertex_attrib_desc.binding, i); |
| 1949 | } |
| 1950 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1951 | if (vertex_attrib_desc.location >= device_limits.maxVertexInputAttributes) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1952 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-location-00620", |
| 1953 | "vkCreateGraphicsPipelines: parameter " |
| 1954 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].location (%u) is " |
| 1955 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputAttributes (%u).", |
| 1956 | i, d, vertex_attrib_desc.location, device_limits.maxVertexInputAttributes); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1957 | } |
| 1958 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1959 | if (vertex_attrib_desc.binding >= device_limits.maxVertexInputBindings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1960 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-binding-00621", |
| 1961 | "vkCreateGraphicsPipelines: parameter " |
| 1962 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].binding (%u) is " |
| 1963 | "greater than or equal to VkPhysicalDeviceLimits::maxVertexInputBindings (%u).", |
| 1964 | i, d, vertex_attrib_desc.binding, device_limits.maxVertexInputBindings); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1965 | } |
| 1966 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 1967 | if (vertex_attrib_desc.offset > device_limits.maxVertexInputAttributeOffset) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 1968 | skip |= LogError(device, "VUID-VkVertexInputAttributeDescription-offset-00622", |
| 1969 | "vkCreateGraphicsPipelines: parameter " |
| 1970 | "pCreateInfos[%u].pVertexInputState->pVertexAttributeDescriptions[%u].offset (%u) is " |
| 1971 | "greater than VkPhysicalDeviceLimits::maxVertexInputAttributeOffset (%u).", |
| 1972 | i, d, vertex_attrib_desc.offset, device_limits.maxVertexInputAttributeOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1973 | } |
| 1974 | } |
| 1975 | } |
| 1976 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1977 | // pTessellationState is ignored without both tessellation control and tessellation evaluation shaders stages |
| 1978 | if (has_control && has_eval) { |
| 1979 | if (pCreateInfos[i].pTessellationState == nullptr) { |
| 1980 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pStages-00731", |
| 1981 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pStages includes a tessellation control " |
| 1982 | "shader stage and a tessellation evaluation shader stage, " |
| 1983 | "pCreateInfos[%d].pTessellationState must not be NULL.", |
| 1984 | i, i); |
| 1985 | } else { |
| 1986 | const VkStructureType allowed_type = VK_STRUCTURE_TYPE_PIPELINE_TESSELLATION_DOMAIN_ORIGIN_STATE_CREATE_INFO; |
| 1987 | skip |= validate_struct_pnext( |
| 1988 | "vkCreateGraphicsPipelines", |
| 1989 | ParameterName("pCreateInfos[%i].pTessellationState->pNext", ParameterName::IndexVector{i}), |
| 1990 | "VkPipelineTessellationDomainOriginStateCreateInfo", pCreateInfos[i].pTessellationState->pNext, 1, |
| 1991 | &allowed_type, GeneratedVulkanHeaderVersion, "VUID-VkGraphicsPipelineCreateInfo-pNext-pNext", |
| 1992 | "VUID-VkGraphicsPipelineCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1993 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1994 | skip |= validate_reserved_flags( |
| 1995 | "vkCreateGraphicsPipelines", |
| 1996 | ParameterName("pCreateInfos[%i].pTessellationState->flags", ParameterName::IndexVector{i}), |
| 1997 | pCreateInfos[i].pTessellationState->flags, "VUID-VkPipelineTessellationStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 1998 | |
Spencer Fricke | f1b0a7d | 2020-03-16 17:38:55 -0700 | [diff] [blame] | 1999 | if (pCreateInfos[i].pTessellationState->patchControlPoints == 0 || |
| 2000 | pCreateInfos[i].pTessellationState->patchControlPoints > device_limits.maxTessellationPatchSize) { |
| 2001 | skip |= LogError(device, "VUID-VkPipelineTessellationStateCreateInfo-patchControlPoints-01214", |
| 2002 | "vkCreateGraphicsPipelines: invalid parameter " |
| 2003 | "pCreateInfos[%d].pTessellationState->patchControlPoints value %u. patchControlPoints " |
| 2004 | "should be >0 and <=%u.", |
| 2005 | i, pCreateInfos[i].pTessellationState->patchControlPoints, |
| 2006 | device_limits.maxTessellationPatchSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2007 | } |
| 2008 | } |
| 2009 | } |
| 2010 | |
| 2011 | // pViewportState, pMultisampleState, pDepthStencilState, and pColorBlendState ignored when rasterization is disabled |
| 2012 | if ((pCreateInfos[i].pRasterizationState != nullptr) && |
| 2013 | (pCreateInfos[i].pRasterizationState->rasterizerDiscardEnable == VK_FALSE)) { |
| 2014 | if (pCreateInfos[i].pViewportState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2015 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00750", |
| 2016 | "vkCreateGraphicsPipelines: Rasterization is enabled (pCreateInfos[%" PRIu32 |
| 2017 | "].pRasterizationState->rasterizerDiscardEnable is VK_FALSE), but pCreateInfos[%" PRIu32 |
| 2018 | "].pViewportState (=NULL) is not a valid pointer.", |
| 2019 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2020 | } else { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2021 | const auto &viewport_state = *pCreateInfos[i].pViewportState; |
| 2022 | |
| 2023 | if (viewport_state.sType != VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2024 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-sType-sType", |
| 2025 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2026 | "].pViewportState->sType is not VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_STATE_CREATE_INFO.", |
| 2027 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2028 | } |
| 2029 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2030 | const VkStructureType allowed_structs_vk_pipeline_viewport_state_create_info[] = { |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2031 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SWIZZLE_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2032 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_W_SCALING_STATE_CREATE_INFO_NV, |
| 2033 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_EXCLUSIVE_SCISSOR_STATE_CREATE_INFO_NV, |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2034 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_SHADING_RATE_IMAGE_STATE_CREATE_INFO_NV, |
| 2035 | VK_STRUCTURE_TYPE_PIPELINE_VIEWPORT_COARSE_SAMPLE_ORDER_STATE_CREATE_INFO_NV, |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2036 | }; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2037 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2038 | "vkCreateGraphicsPipelines", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2039 | ParameterName("pCreateInfos[%i].pViewportState->pNext", ParameterName::IndexVector{i}), |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2040 | "VkPipelineViewportSwizzleStateCreateInfoNV, VkPipelineViewportWScalingStateCreateInfoNV, " |
Jeff Bolz | b8a8dd0 | 2018-09-18 02:39:24 -0500 | [diff] [blame] | 2041 | "VkPipelineViewportExclusiveScissorStateCreateInfoNV, VkPipelineViewportShadingRateImageStateCreateInfoNV, " |
| 2042 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2043 | viewport_state.pNext, ARRAY_SIZE(allowed_structs_vk_pipeline_viewport_state_create_info), |
| 2044 | allowed_structs_vk_pipeline_viewport_state_create_info, 65, |
| 2045 | "VUID-VkPipelineViewportStateCreateInfo-pNext-pNext", |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2046 | "VUID-VkPipelineViewportStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2047 | |
| 2048 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2049 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2050 | ParameterName("pCreateInfos[%i].pViewportState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2051 | viewport_state.flags, "VUID-VkPipelineViewportStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2052 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2053 | auto exclusive_scissor_struct = lvl_find_in_chain<VkPipelineViewportExclusiveScissorStateCreateInfoNV>( |
| 2054 | pCreateInfos[i].pViewportState->pNext); |
| 2055 | auto shading_rate_image_struct = lvl_find_in_chain<VkPipelineViewportShadingRateImageStateCreateInfoNV>( |
| 2056 | pCreateInfos[i].pViewportState->pNext); |
| 2057 | auto coarse_sample_order_struct = lvl_find_in_chain<VkPipelineViewportCoarseSampleOrderStateCreateInfoNV>( |
| 2058 | pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2059 | const auto vp_swizzle_struct = |
| 2060 | lvl_find_in_chain<VkPipelineViewportSwizzleStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2061 | const auto vp_w_scaling_struct = |
| 2062 | lvl_find_in_chain<VkPipelineViewportWScalingStateCreateInfoNV>(pCreateInfos[i].pViewportState->pNext); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2063 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2064 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | 8b9ddab | 2020-10-15 14:38:43 -0600 | [diff] [blame] | 2065 | if (!has_dynamic_viewport_with_count && (viewport_state.viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2066 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01216", |
| 2067 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2068 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 |
| 2069 | ") is not 1.", |
| 2070 | i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2071 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2072 | |
Mark Lobodzinski | 8b9ddab | 2020-10-15 14:38:43 -0600 | [diff] [blame] | 2073 | if (!has_dynamic_scissor_with_count && (viewport_state.scissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2074 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01217", |
| 2075 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2076 | "disabled, but pCreateInfos[%" PRIu32 "].pViewportState->scissorCount (=%" PRIu32 |
| 2077 | ") is not 1.", |
| 2078 | i, viewport_state.scissorCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2079 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2080 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2081 | if (exclusive_scissor_struct && (exclusive_scissor_struct->exclusiveScissorCount != 0 && |
| 2082 | exclusive_scissor_struct->exclusiveScissorCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2083 | skip |= LogError( |
| 2084 | device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02027", |
| 2085 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2086 | "disabled, but pCreateInfos[%" PRIu32 |
| 2087 | "] VkPipelineViewportExclusiveScissorStateCreateInfoNV::exclusiveScissorCount (=%" PRIu32 |
| 2088 | ") is not 1.", |
| 2089 | i, exclusive_scissor_struct->exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2090 | } |
| 2091 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2092 | if (shading_rate_image_struct && |
| 2093 | (shading_rate_image_struct->viewportCount != 0 && shading_rate_image_struct->viewportCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2094 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02054", |
| 2095 | "vkCreateGraphicsPipelines: The VkPhysicalDeviceFeatures::multiViewport feature is " |
| 2096 | "disabled, but pCreateInfos[%" PRIu32 |
| 2097 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV::viewportCount (=%" PRIu32 |
| 2098 | ") is neither 0 nor 1.", |
| 2099 | i, shading_rate_image_struct->viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2100 | } |
| 2101 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2102 | } else { // multiViewport enabled |
| 2103 | if (viewport_state.viewportCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2104 | if (!has_dynamic_viewport_with_count) { |
| 2105 | skip |= LogError( |
| 2106 | device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-arraylength", |
| 2107 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->viewportCount is 0.", i); |
| 2108 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2109 | } else if (viewport_state.viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2110 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportCount-01218", |
| 2111 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2112 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2113 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2114 | i, viewport_state.viewportCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2115 | } else if (has_dynamic_viewport_with_count) { |
| 2116 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03379", |
| 2117 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2118 | "].pViewportState->viewportCount (=%" PRIu32 |
| 2119 | ") must be zero when VK_DYNAMIC_STATE_VIEWPORT_WITH_COUNT_EXT is used.", |
| 2120 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2121 | } |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2122 | |
| 2123 | if (viewport_state.scissorCount == 0) { |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2124 | if (!has_dynamic_scissor_with_count) { |
| 2125 | skip |= LogError( |
| 2126 | device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-arraylength", |
| 2127 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "].pViewportState->scissorCount is 0.", i); |
| 2128 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2129 | } else if (viewport_state.scissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2130 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01219", |
| 2131 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2132 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2133 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2134 | i, viewport_state.scissorCount, device_limits.maxViewports); |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2135 | } else if (has_dynamic_scissor_with_count) { |
| 2136 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-03380", |
| 2137 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2138 | "].pViewportState->scissorCount (=%" PRIu32 |
| 2139 | ") must be zero when VK_DYNAMIC_STATE_SCISSOR_WITH_COUNT_EXT is used.", |
| 2140 | i, viewport_state.viewportCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2141 | } |
| 2142 | } |
| 2143 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2144 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2145 | skip |= |
| 2146 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02028", |
| 2147 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2148 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2149 | i, exclusive_scissor_struct->exclusiveScissorCount, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2150 | } |
| 2151 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2152 | if (shading_rate_image_struct && shading_rate_image_struct->viewportCount > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2153 | skip |= LogError(device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-viewportCount-02055", |
| 2154 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2155 | "] VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2156 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 2157 | i, shading_rate_image_struct->viewportCount, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2158 | } |
| 2159 | |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 2160 | if (viewport_state.scissorCount != viewport_state.viewportCount && |
| 2161 | !(has_dynamic_viewport_with_count || has_dynamic_scissor_with_count)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2162 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-scissorCount-01220", |
| 2163 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2164 | "].pViewportState->scissorCount (=%" PRIu32 ") is not identical to pCreateInfos[%" PRIu32 |
| 2165 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2166 | i, viewport_state.scissorCount, i, viewport_state.viewportCount); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2167 | } |
| 2168 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2169 | if (exclusive_scissor_struct && exclusive_scissor_struct->exclusiveScissorCount != 0 && |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2170 | exclusive_scissor_struct->exclusiveScissorCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2171 | skip |= |
| 2172 | LogError(device, "VUID-VkPipelineViewportExclusiveScissorStateCreateInfoNV-exclusiveScissorCount-02029", |
| 2173 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 "] exclusiveScissorCount (=%" PRIu32 |
| 2174 | ") must be zero or identical to pCreateInfos[%" PRIu32 |
| 2175 | "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2176 | i, exclusive_scissor_struct->exclusiveScissorCount, i, viewport_state.viewportCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2177 | } |
| 2178 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2179 | if (shading_rate_image_struct && shading_rate_image_struct->shadingRateImageEnable && |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2180 | shading_rate_image_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2181 | skip |= LogError( |
| 2182 | device, "VUID-VkPipelineViewportShadingRateImageStateCreateInfoNV-shadingRateImageEnable-02056", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2183 | "vkCreateGraphicsPipelines: If shadingRateImageEnable is enabled, pCreateInfos[%" PRIu32 |
| 2184 | "] " |
| 2185 | "VkPipelineViewportShadingRateImageStateCreateInfoNV viewportCount (=%" PRIu32 |
| 2186 | ") must identical to pCreateInfos[%" PRIu32 "].pViewportState->viewportCount (=%" PRIu32 ").", |
| 2187 | i, shading_rate_image_struct->viewportCount, i, viewport_state.viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2188 | } |
| 2189 | |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2190 | if (!has_dynamic_viewport && viewport_state.viewportCount > 0 && viewport_state.pViewports == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2191 | skip |= LogError( |
| 2192 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00747", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2193 | "vkCreateGraphicsPipelines: The viewport state is static (pCreateInfos[%" PRIu32 |
| 2194 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2195 | "].pViewportState->pViewports (=NULL) is an invalid pointer.", |
| 2196 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2197 | } |
| 2198 | |
| 2199 | if (!has_dynamic_scissor && viewport_state.scissorCount > 0 && viewport_state.pScissors == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2200 | skip |= LogError( |
| 2201 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00748", |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2202 | "vkCreateGraphicsPipelines: The scissor state is static (pCreateInfos[%" PRIu32 |
| 2203 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_SCISSOR), but pCreateInfos[%" PRIu32 |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 2204 | "].pViewportState->pScissors (=NULL) is an invalid pointer.", |
| 2205 | i, i); |
Petr Kraus | a610355 | 2017-11-16 21:21:58 +0100 | [diff] [blame] | 2206 | } |
| 2207 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2208 | if (!has_dynamic_exclusive_scissor_nv && exclusive_scissor_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2209 | exclusive_scissor_struct->exclusiveScissorCount > 0 && |
| 2210 | exclusive_scissor_struct->pExclusiveScissors == nullptr) { |
| 2211 | skip |= |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2212 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04056", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2213 | "vkCreateGraphicsPipelines: The exclusive scissor state is static (pCreateInfos[%" PRIu32 |
| 2214 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV), but " |
| 2215 | "pCreateInfos[%" PRIu32 "] pExclusiveScissors (=NULL) is an invalid pointer.", |
| 2216 | i, i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2217 | } |
| 2218 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2219 | if (!has_dynamic_shading_rate_palette_nv && shading_rate_image_struct && |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2220 | shading_rate_image_struct->viewportCount > 0 && |
| 2221 | shading_rate_image_struct->pShadingRatePalettes == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2222 | skip |= LogError( |
Shannon McPherson | 24c13d1 | 2020-06-18 15:51:41 -0600 | [diff] [blame] | 2223 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-04057", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2224 | "vkCreateGraphicsPipelines: The shading rate palette state is static (pCreateInfos[%" PRIu32 |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 2225 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_VIEWPORT_SHADING_RATE_PALETTE_NV), " |
| 2226 | "but pCreateInfos[%" PRIu32 "] pShadingRatePalettes (=NULL) is an invalid pointer.", |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2227 | i, i); |
| 2228 | } |
| 2229 | |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2230 | if (vp_swizzle_struct) { |
| 2231 | if (vp_swizzle_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2232 | skip |= LogError(device, "VUID-VkPipelineViewportSwizzleStateCreateInfoNV-viewportCount-01215", |
| 2233 | "vkCreateGraphicsPipelines: The viewport swizzle state vieport count of %" PRIu32 |
| 2234 | " does " |
| 2235 | "not match the viewport count of %" PRIu32 " in VkPipelineViewportStateCreateInfo.", |
| 2236 | vp_swizzle_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 328d821 | 2018-12-11 14:16:18 +0100 | [diff] [blame] | 2237 | } |
| 2238 | } |
| 2239 | |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2240 | // validate the VkViewports |
| 2241 | if (!has_dynamic_viewport && viewport_state.pViewports) { |
| 2242 | for (uint32_t viewport_i = 0; viewport_i < viewport_state.viewportCount; ++viewport_i) { |
| 2243 | const auto &viewport = viewport_state.pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 2244 | const char *fn_name = "vkCreateGraphicsPipelines"; |
| 2245 | skip |= manual_PreCallValidateViewport(viewport, fn_name, |
| 2246 | ParameterName("pCreateInfos[%i].pViewportState->pViewports[%i]", |
| 2247 | ParameterName::IndexVector{i, viewport_i}), |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2248 | VkCommandBuffer(0)); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 2249 | } |
| 2250 | } |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2251 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2252 | if (has_dynamic_viewport_w_scaling_nv && !device_extensions.vk_nv_clip_space_w_scaling) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2253 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2254 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2255 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_VIEWPORT_W_SCALING_NV, but " |
| 2256 | "VK_NV_clip_space_w_scaling extension is not enabled.", |
| 2257 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2258 | } |
| 2259 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2260 | if (has_dynamic_discard_rectangle_ext && !device_extensions.vk_ext_discard_rectangles) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2261 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2262 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2263 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_DISCARD_RECTANGLE_EXT, but " |
| 2264 | "VK_EXT_discard_rectangles extension is not enabled.", |
| 2265 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2266 | } |
| 2267 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2268 | if (has_dynamic_sample_locations_ext && !device_extensions.vk_ext_sample_locations) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2269 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2270 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2271 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_SAMPLE_LOCATIONS_EXT, but " |
| 2272 | "VK_EXT_sample_locations extension is not enabled.", |
| 2273 | i); |
Jeremy Kniager | 71fd5f0 | 2017-11-15 13:27:03 -0700 | [diff] [blame] | 2274 | } |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2275 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2276 | if (has_dynamic_exclusive_scissor_nv && !device_extensions.vk_nv_scissor_exclusive) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2277 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 2278 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2279 | "].pDynamicState->pDynamicStates contains VK_DYNAMIC_STATE_EXCLUSIVE_SCISSOR_NV, but " |
| 2280 | "VK_NV_scissor_exclusive extension is not enabled.", |
| 2281 | i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 2282 | } |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2283 | |
| 2284 | if (coarse_sample_order_struct && |
| 2285 | coarse_sample_order_struct->sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && |
| 2286 | coarse_sample_order_struct->customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2287 | skip |= LogError(device, "VUID-VkPipelineViewportCoarseSampleOrderStateCreateInfoNV-sampleOrderType-02072", |
| 2288 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2289 | "] " |
| 2290 | "VkPipelineViewportCoarseSampleOrderStateCreateInfoNV sampleOrderType is not " |
| 2291 | "VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV and customSampleOrderCount is not 0.", |
| 2292 | i); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2293 | } |
| 2294 | |
| 2295 | if (coarse_sample_order_struct) { |
| 2296 | for (uint32_t order_i = 0; order_i < coarse_sample_order_struct->customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2297 | skip |= ValidateCoarseSampleOrderCustomNV(&coarse_sample_order_struct->pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 2298 | } |
| 2299 | } |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2300 | |
| 2301 | if (vp_w_scaling_struct && (vp_w_scaling_struct->viewportWScalingEnable == VK_TRUE)) { |
| 2302 | if (vp_w_scaling_struct->viewportCount != viewport_state.viewportCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2303 | skip |= LogError(device, "VUID-VkPipelineViewportStateCreateInfo-viewportWScalingEnable-01726", |
| 2304 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2305 | "] " |
| 2306 | "VkPipelineViewportWScalingStateCreateInfoNV.viewportCount (=%" PRIu32 |
| 2307 | ") " |
| 2308 | "is not equal to VkPipelineViewportStateCreateInfo.viewportCount (=%" PRIu32 ").", |
| 2309 | i, vp_w_scaling_struct->viewportCount, viewport_state.viewportCount); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2310 | } |
| 2311 | if (!has_dynamic_viewport_w_scaling_nv && !vp_w_scaling_struct->pViewportWScalings) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2312 | skip |= LogError( |
| 2313 | device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-01715", |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 2314 | "vkCreateGraphicsPipelines: pCreateInfos[%" PRIu32 |
| 2315 | "] " |
| 2316 | "VkPipelineViewportWScalingStateCreateInfoNV.pViewportWScalings (=NULL) is not a valid array.", |
| 2317 | i); |
| 2318 | } |
| 2319 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2320 | } |
| 2321 | |
| 2322 | if (pCreateInfos[i].pMultisampleState == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2323 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-rasterizerDiscardEnable-00751", |
| 2324 | "vkCreateGraphicsPipelines: if pCreateInfos[%d].pRasterizationState->rasterizerDiscardEnable " |
| 2325 | "is VK_FALSE, pCreateInfos[%d].pMultisampleState must not be NULL.", |
| 2326 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2327 | } else { |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2328 | const VkStructureType valid_next_stypes[] = {LvlTypeMap<VkPipelineCoverageModulationStateCreateInfoNV>::kSType, |
Mark Lobodzinski | 1ddf16f | 2020-08-13 08:58:13 -0600 | [diff] [blame] | 2329 | LvlTypeMap<VkPipelineCoverageReductionStateCreateInfoNV>::kSType, |
Dave Houlton | b3bbec7 | 2018-01-17 10:13:33 -0700 | [diff] [blame] | 2330 | LvlTypeMap<VkPipelineCoverageToColorStateCreateInfoNV>::kSType, |
| 2331 | LvlTypeMap<VkPipelineSampleLocationsStateCreateInfoEXT>::kSType}; |
Mike Schuchardt | 97662b0 | 2017-12-06 13:31:29 -0700 | [diff] [blame] | 2332 | const char *valid_struct_names = |
Dave Houlton | a9df0ce | 2018-02-07 10:51:23 -0700 | [diff] [blame] | 2333 | "VkPipelineCoverageModulationStateCreateInfoNV, VkPipelineCoverageToColorStateCreateInfoNV, " |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 2334 | "VkPipelineSampleLocationsStateCreateInfoEXT"; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2335 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2336 | "vkCreateGraphicsPipelines", |
John Zulauf | 96b0e42 | 2017-11-14 11:43:19 -0700 | [diff] [blame] | 2337 | ParameterName("pCreateInfos[%i].pMultisampleState->pNext", ParameterName::IndexVector{i}), |
Mark Lobodzinski | 1ddf16f | 2020-08-13 08:58:13 -0600 | [diff] [blame] | 2338 | valid_struct_names, pCreateInfos[i].pMultisampleState->pNext, 4, valid_next_stypes, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2339 | GeneratedVulkanHeaderVersion, "VUID-VkPipelineMultisampleStateCreateInfo-pNext-pNext", |
| 2340 | "VUID-VkPipelineMultisampleStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2341 | |
| 2342 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2343 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2344 | ParameterName("pCreateInfos[%i].pMultisampleState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2345 | pCreateInfos[i].pMultisampleState->flags, "VUID-VkPipelineMultisampleStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2346 | |
| 2347 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2348 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2349 | ParameterName("pCreateInfos[%i].pMultisampleState->sampleShadingEnable", ParameterName::IndexVector{i}), |
| 2350 | pCreateInfos[i].pMultisampleState->sampleShadingEnable); |
| 2351 | |
| 2352 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2353 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2354 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 2355 | ParameterName("pCreateInfos[%i].pMultisampleState->pSampleMask", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 2356 | pCreateInfos[i].pMultisampleState->rasterizationSamples, &pCreateInfos[i].pMultisampleState->pSampleMask, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2357 | true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2358 | |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2359 | skip |= validate_flags( |
| 2360 | "vkCreateGraphicsPipelines", |
| 2361 | ParameterName("pCreateInfos[%i].pMultisampleState->rasterizationSamples", ParameterName::IndexVector{i}), |
| 2362 | "VkSampleCountFlagBits", AllVkSampleCountFlagBits, pCreateInfos[i].pMultisampleState->rasterizationSamples, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2363 | kRequiredSingleBit, "VUID-VkPipelineMultisampleStateCreateInfo-rasterizationSamples-parameter"); |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2364 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2365 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2366 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2367 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToCoverageEnable", ParameterName::IndexVector{i}), |
| 2368 | pCreateInfos[i].pMultisampleState->alphaToCoverageEnable); |
| 2369 | |
| 2370 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2371 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2372 | ParameterName("pCreateInfos[%i].pMultisampleState->alphaToOneEnable", ParameterName::IndexVector{i}), |
| 2373 | pCreateInfos[i].pMultisampleState->alphaToOneEnable); |
| 2374 | |
| 2375 | if (pCreateInfos[i].pMultisampleState->sType != VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO) { |
sfricke-samsung | 81c56f7 | 2020-08-23 22:14:41 -0700 | [diff] [blame] | 2376 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sType-sType", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2377 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pMultisampleState->sType must be " |
| 2378 | "VK_STRUCTURE_TYPE_PIPELINE_MULTISAMPLE_STATE_CREATE_INFO", |
| 2379 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2380 | } |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2381 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable == VK_TRUE) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2382 | if (!physical_device_features.sampleRateShading) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2383 | skip |= LogError(device, "VUID-VkPipelineMultisampleStateCreateInfo-sampleShadingEnable-00784", |
| 2384 | "vkCreateGraphicsPipelines(): parameter " |
| 2385 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable.", |
| 2386 | i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2387 | } |
| 2388 | // TODO Add documentation issue about when minSampleShading must be in range and when it is ignored |
| 2389 | // For now a "least noise" test *only* when sampleShadingEnable is VK_TRUE. |
| 2390 | if (!in_inclusive_range(pCreateInfos[i].pMultisampleState->minSampleShading, 0.F, 1.0F)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2391 | skip |= LogError( |
| 2392 | device, |
| 2393 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2394 | "VUID-VkPipelineMultisampleStateCreateInfo-minSampleShading-00786", |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 2395 | "vkCreateGraphicsPipelines(): parameter pCreateInfos[%d].pMultisampleState->minSampleShading.", i); |
John Zulauf | 7acac59 | 2017-11-06 11:15:53 -0700 | [diff] [blame] | 2396 | } |
| 2397 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2398 | |
| 2399 | const auto *line_state = lvl_find_in_chain<VkPipelineRasterizationLineStateCreateInfoEXT>( |
| 2400 | pCreateInfos[i].pRasterizationState->pNext); |
| 2401 | |
| 2402 | if (line_state) { |
| 2403 | if ((line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT || |
| 2404 | line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT)) { |
| 2405 | if (pCreateInfos[i].pMultisampleState->alphaToCoverageEnable) { |
| 2406 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2407 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2408 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2409 | "pCreateInfos[%d].pMultisampleState->alphaToCoverageEnable == VK_TRUE.", |
| 2410 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2411 | } |
| 2412 | if (pCreateInfos[i].pMultisampleState->alphaToOneEnable) { |
| 2413 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2414 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2415 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2416 | "pCreateInfos[%d].pMultisampleState->alphaToOneEnable == VK_TRUE.", |
| 2417 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2418 | } |
| 2419 | if (pCreateInfos[i].pMultisampleState->sampleShadingEnable) { |
| 2420 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2421 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-lineRasterizationMode-02766", |
| 2422 | "vkCreateGraphicsPipelines(): Bresenham/Smooth line rasterization not supported with " |
| 2423 | "pCreateInfos[%d].pMultisampleState->sampleShadingEnable == VK_TRUE.", |
| 2424 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2425 | } |
| 2426 | } |
| 2427 | if (line_state->stippledLineEnable && !has_dynamic_line_stipple) { |
| 2428 | if (line_state->lineStippleFactor < 1 || line_state->lineStippleFactor > 256) { |
| 2429 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2430 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-stippledLineEnable-02767", |
| 2431 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineStippleFactor = %d must be in the " |
| 2432 | "range [1,256].", |
| 2433 | i, line_state->lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2434 | } |
| 2435 | } |
| 2436 | const auto *line_features = |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 2437 | lvl_find_in_chain<VkPhysicalDeviceLineRasterizationFeaturesEXT>(device_createinfo_pnext); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2438 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2439 | (!line_features || !line_features->rectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2440 | skip |= |
| 2441 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02768", |
| 2442 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2443 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT requires the rectangularLines feature.", |
| 2444 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2445 | } |
| 2446 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2447 | (!line_features || !line_features->bresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2448 | skip |= |
| 2449 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02769", |
| 2450 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2451 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT requires the bresenhamLines feature.", |
| 2452 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2453 | } |
| 2454 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2455 | (!line_features || !line_features->smoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2456 | skip |= |
| 2457 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-lineRasterizationMode-02770", |
| 2458 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2459 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT requires the smoothLines feature.", |
| 2460 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2461 | } |
| 2462 | if (line_state->stippledLineEnable) { |
| 2463 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT && |
| 2464 | (!line_features || !line_features->stippledRectangularLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2465 | skip |= |
| 2466 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02771", |
| 2467 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2468 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_EXT with stipple requires the " |
| 2469 | "stippledRectangularLines feature.", |
| 2470 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2471 | } |
| 2472 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT && |
| 2473 | (!line_features || !line_features->stippledBresenhamLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2474 | skip |= |
| 2475 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02772", |
| 2476 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2477 | "VK_LINE_RASTERIZATION_MODE_BRESENHAM_EXT with stipple requires the " |
| 2478 | "stippledBresenhamLines feature.", |
| 2479 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2480 | } |
| 2481 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT && |
| 2482 | (!line_features || !line_features->stippledSmoothLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2483 | skip |= |
| 2484 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02773", |
| 2485 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2486 | "VK_LINE_RASTERIZATION_MODE_RECTANGULAR_SMOOTH_EXT with stipple requires the " |
| 2487 | "stippledSmoothLines feature.", |
| 2488 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2489 | } |
| 2490 | if (line_state->lineRasterizationMode == VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT && |
| 2491 | (!line_features || !line_features->stippledSmoothLines || !device_limits.strictLines)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2492 | skip |= |
| 2493 | LogError(device, "VUID-VkPipelineRasterizationLineStateCreateInfoEXT-stippledLineEnable-02774", |
| 2494 | "vkCreateGraphicsPipelines(): pCreateInfos[%d] lineRasterizationMode = " |
| 2495 | "VK_LINE_RASTERIZATION_MODE_DEFAULT_EXT with stipple requires the " |
| 2496 | "stippledRectangularLines and strictLines features.", |
| 2497 | i); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 2498 | } |
| 2499 | } |
| 2500 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2501 | } |
| 2502 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2503 | bool uses_color_attachment = false; |
| 2504 | bool uses_depthstencil_attachment = false; |
| 2505 | { |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2506 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2507 | const auto subpasses_uses_it = renderpasses_states.find(pCreateInfos[i].renderPass); |
| 2508 | if (subpasses_uses_it != renderpasses_states.end()) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2509 | const auto &subpasses_uses = subpasses_uses_it->second; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2510 | if (subpasses_uses.subpasses_using_color_attachment.count(pCreateInfos[i].subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2511 | uses_color_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2512 | } |
| 2513 | if (subpasses_uses.subpasses_using_depthstencil_attachment.count(pCreateInfos[i].subpass)) { |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2514 | uses_depthstencil_attachment = true; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2515 | } |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2516 | } |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 2517 | lock.unlock(); |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2518 | } |
| 2519 | |
| 2520 | if (pCreateInfos[i].pDepthStencilState != nullptr && uses_depthstencil_attachment) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2521 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2522 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2523 | ParameterName("pCreateInfos[%i].pDepthStencilState->pNext", ParameterName::IndexVector{i}), NULL, |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2524 | pCreateInfos[i].pDepthStencilState->pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2525 | "VUID-VkPipelineDepthStencilStateCreateInfo-pNext-pNext", nullptr); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2526 | |
| 2527 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2528 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2529 | ParameterName("pCreateInfos[%i].pDepthStencilState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2530 | pCreateInfos[i].pDepthStencilState->flags, "VUID-VkPipelineDepthStencilStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2531 | |
| 2532 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2533 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2534 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthTestEnable", ParameterName::IndexVector{i}), |
| 2535 | pCreateInfos[i].pDepthStencilState->depthTestEnable); |
| 2536 | |
| 2537 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2538 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2539 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthWriteEnable", ParameterName::IndexVector{i}), |
| 2540 | pCreateInfos[i].pDepthStencilState->depthWriteEnable); |
| 2541 | |
| 2542 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2543 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2544 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthCompareOp", ParameterName::IndexVector{i}), |
| 2545 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->depthCompareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2546 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2547 | |
| 2548 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2549 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2550 | ParameterName("pCreateInfos[%i].pDepthStencilState->depthBoundsTestEnable", ParameterName::IndexVector{i}), |
| 2551 | pCreateInfos[i].pDepthStencilState->depthBoundsTestEnable); |
| 2552 | |
| 2553 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2554 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2555 | ParameterName("pCreateInfos[%i].pDepthStencilState->stencilTestEnable", ParameterName::IndexVector{i}), |
| 2556 | pCreateInfos[i].pDepthStencilState->stencilTestEnable); |
| 2557 | |
| 2558 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2559 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2560 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.failOp", ParameterName::IndexVector{i}), |
| 2561 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2562 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2563 | |
| 2564 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2565 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2566 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.passOp", ParameterName::IndexVector{i}), |
| 2567 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2568 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2569 | |
| 2570 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2571 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2572 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.depthFailOp", ParameterName::IndexVector{i}), |
| 2573 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->front.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2574 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2575 | |
| 2576 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2577 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2578 | ParameterName("pCreateInfos[%i].pDepthStencilState->front.compareOp", ParameterName::IndexVector{i}), |
| 2579 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->front.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2580 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2581 | |
| 2582 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2583 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2584 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.failOp", ParameterName::IndexVector{i}), |
| 2585 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.failOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2586 | "VUID-VkStencilOpState-failOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2587 | |
| 2588 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2589 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2590 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.passOp", ParameterName::IndexVector{i}), |
| 2591 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.passOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2592 | "VUID-VkStencilOpState-passOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2593 | |
| 2594 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2595 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2596 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.depthFailOp", ParameterName::IndexVector{i}), |
| 2597 | "VkStencilOp", AllVkStencilOpEnums, pCreateInfos[i].pDepthStencilState->back.depthFailOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2598 | "VUID-VkStencilOpState-depthFailOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2599 | |
| 2600 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2601 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2602 | ParameterName("pCreateInfos[%i].pDepthStencilState->back.compareOp", ParameterName::IndexVector{i}), |
| 2603 | "VkCompareOp", AllVkCompareOpEnums, pCreateInfos[i].pDepthStencilState->back.compareOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2604 | "VUID-VkPipelineDepthStencilStateCreateInfo-depthCompareOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2605 | |
| 2606 | if (pCreateInfos[i].pDepthStencilState->sType != VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO) { |
sfricke-samsung | 81c56f7 | 2020-08-23 22:14:41 -0700 | [diff] [blame] | 2607 | skip |= LogError(device, "VUID-VkPipelineDepthStencilStateCreateInfo-sType-sType", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2608 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pDepthStencilState->sType must be " |
| 2609 | "VK_STRUCTURE_TYPE_PIPELINE_DEPTH_STENCIL_STATE_CREATE_INFO", |
| 2610 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2611 | } |
| 2612 | } |
| 2613 | |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2614 | const VkStructureType allowed_structs_vk_pipeline_color_blend_state_create_info[] = { |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2615 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_ADVANCED_STATE_CREATE_INFO_EXT}; |
| 2616 | |
Petr Kraus | e91f7a1 | 2017-12-14 20:57:36 +0100 | [diff] [blame] | 2617 | if (pCreateInfos[i].pColorBlendState != nullptr && uses_color_attachment) { |
Mark Lobodzinski | 876d5b5 | 2019-08-06 16:32:27 -0600 | [diff] [blame] | 2618 | skip |= validate_struct_type("vkCreateGraphicsPipelines", |
| 2619 | ParameterName("pCreateInfos[%i].pColorBlendState", ParameterName::IndexVector{i}), |
| 2620 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 2621 | pCreateInfos[i].pColorBlendState, |
| 2622 | VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO, false, kVUIDUndefined, |
| 2623 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType"); |
| 2624 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2625 | skip |= validate_struct_pnext( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2626 | "vkCreateGraphicsPipelines", |
Shannon McPherson | 9b9532b | 2018-10-24 12:00:09 -0600 | [diff] [blame] | 2627 | ParameterName("pCreateInfos[%i].pColorBlendState->pNext", ParameterName::IndexVector{i}), |
| 2628 | "VkPipelineColorBlendAdvancedStateCreateInfoEXT", pCreateInfos[i].pColorBlendState->pNext, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2629 | ARRAY_SIZE(allowed_structs_vk_pipeline_color_blend_state_create_info), |
| 2630 | allowed_structs_vk_pipeline_color_blend_state_create_info, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 2631 | "VUID-VkPipelineColorBlendStateCreateInfo-pNext-pNext", |
| 2632 | "VUID-VkPipelineColorBlendStateCreateInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2633 | |
| 2634 | skip |= validate_reserved_flags( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2635 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2636 | ParameterName("pCreateInfos[%i].pColorBlendState->flags", ParameterName::IndexVector{i}), |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2637 | pCreateInfos[i].pColorBlendState->flags, "VUID-VkPipelineColorBlendStateCreateInfo-flags-zerobitmask"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2638 | |
| 2639 | skip |= validate_bool32( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2640 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2641 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOpEnable", ParameterName::IndexVector{i}), |
| 2642 | pCreateInfos[i].pColorBlendState->logicOpEnable); |
| 2643 | |
| 2644 | skip |= validate_array( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2645 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2646 | ParameterName("pCreateInfos[%i].pColorBlendState->attachmentCount", ParameterName::IndexVector{i}), |
| 2647 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments", ParameterName::IndexVector{i}), |
GabrÃel Arthúr Pétursson | 092b29b | 2018-03-21 22:44:11 +0000 | [diff] [blame] | 2648 | pCreateInfos[i].pColorBlendState->attachmentCount, &pCreateInfos[i].pColorBlendState->pAttachments, false, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2649 | true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2650 | |
| 2651 | if (pCreateInfos[i].pColorBlendState->pAttachments != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2652 | for (uint32_t attachment_index = 0; attachment_index < pCreateInfos[i].pColorBlendState->attachmentCount; |
| 2653 | ++attachment_index) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2654 | skip |= validate_bool32("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2655 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].blendEnable", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2656 | ParameterName::IndexVector{i, attachment_index}), |
| 2657 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].blendEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2658 | |
| 2659 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2660 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2661 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2662 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2663 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2664 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2665 | "VUID-VkPipelineColorBlendAttachmentState-srcColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2666 | |
| 2667 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2668 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2669 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstColorBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2670 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2671 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2672 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstColorBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2673 | "VUID-VkPipelineColorBlendAttachmentState-dstColorBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2674 | |
| 2675 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2676 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2677 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2678 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2679 | "VkBlendOp", AllVkBlendOpEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2680 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2681 | "VUID-VkPipelineColorBlendAttachmentState-colorBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2682 | |
| 2683 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2684 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2685 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].srcAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2686 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2687 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2688 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].srcAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2689 | "VUID-VkPipelineColorBlendAttachmentState-srcAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2690 | |
| 2691 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2692 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2693 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].dstAlphaBlendFactor", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2694 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2695 | "VkBlendFactor", AllVkBlendFactorEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2696 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].dstAlphaBlendFactor, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2697 | "VUID-VkPipelineColorBlendAttachmentState-dstAlphaBlendFactor-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2698 | |
| 2699 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2700 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2701 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].alphaBlendOp", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2702 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2703 | "VkBlendOp", AllVkBlendOpEnums, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2704 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].alphaBlendOp, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2705 | "VUID-VkPipelineColorBlendAttachmentState-alphaBlendOp-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2706 | |
| 2707 | skip |= |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2708 | validate_flags("vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2709 | ParameterName("pCreateInfos[%i].pColorBlendState->pAttachments[%i].colorWriteMask", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2710 | ParameterName::IndexVector{i, attachment_index}), |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2711 | "VkColorComponentFlagBits", AllVkColorComponentFlagBits, |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 2712 | pCreateInfos[i].pColorBlendState->pAttachments[attachment_index].colorWriteMask, |
Petr Kraus | 52758be | 2019-08-12 00:53:58 +0200 | [diff] [blame] | 2713 | kOptionalFlags, "VUID-VkPipelineColorBlendAttachmentState-colorWriteMask-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2714 | } |
| 2715 | } |
| 2716 | |
| 2717 | if (pCreateInfos[i].pColorBlendState->sType != VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO) { |
sfricke-samsung | 81c56f7 | 2020-08-23 22:14:41 -0700 | [diff] [blame] | 2718 | skip |= LogError(device, "VUID-VkPipelineColorBlendStateCreateInfo-sType-sType", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2719 | "vkCreateGraphicsPipelines: parameter pCreateInfos[%d].pColorBlendState->sType must be " |
| 2720 | "VK_STRUCTURE_TYPE_PIPELINE_COLOR_BLEND_STATE_CREATE_INFO", |
| 2721 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2722 | } |
| 2723 | |
| 2724 | // If logicOpEnable is VK_TRUE, logicOp must be a valid VkLogicOp value |
| 2725 | if (pCreateInfos[i].pColorBlendState->logicOpEnable == VK_TRUE) { |
| 2726 | skip |= validate_ranged_enum( |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2727 | "vkCreateGraphicsPipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2728 | ParameterName("pCreateInfos[%i].pColorBlendState->logicOp", ParameterName::IndexVector{i}), "VkLogicOp", |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2729 | AllVkLogicOpEnums, pCreateInfos[i].pColorBlendState->logicOp, |
| 2730 | "VUID-VkPipelineColorBlendStateCreateInfo-logicOpEnable-00607"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2731 | } |
| 2732 | } |
| 2733 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2734 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2735 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 2736 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 2737 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2738 | skip |= |
| 2739 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00724", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2740 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineHandle, must be " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2741 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2742 | "and pCreateInfos->basePipelineIndex is not -1.", |
| 2743 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2744 | } |
| 2745 | } |
| 2746 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2747 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 2748 | if (pCreateInfos[i].basePipelineIndex != -1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2749 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00725", |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2750 | "vkCreateGraphicsPipelines parameter, pCreateInfos[%u]->basePipelineIndex, must be -1 if " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2751 | "pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag and " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2752 | "pCreateInfos->basePipelineHandle is not VK_NULL_HANDLE.", |
| 2753 | i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2754 | } |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2755 | } else { |
Mike Schuchardt | e5c15cf | 2020-04-06 22:57:13 -0700 | [diff] [blame] | 2756 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2757 | skip |= |
| 2758 | LogError(device, "VUID-VkGraphicsPipelineCreateInfo-flags-00723", |
| 2759 | "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->basePipelineIndex (%d) must be a valid" |
| 2760 | "index into the pCreateInfos array, of size %d.", |
| 2761 | i, pCreateInfos[i].basePipelineIndex, createInfoCount); |
Mark Lobodzinski | 4dfeb94 | 2019-09-13 12:11:13 -0600 | [diff] [blame] | 2762 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2763 | } |
| 2764 | } |
| 2765 | |
sfricke-samsung | 898cf22 | 2020-05-15 23:10:19 -0700 | [diff] [blame] | 2766 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) != 0) { |
| 2767 | skip |= LogError( |
| 2768 | device, "VUID-VkGraphicsPipelineCreateInfo-flags-00764", |
| 2769 | "vkCreateGraphicsPipelines parameter pCreateInfos[%u]->flags must not contain VK_PIPELINE_CREATE_DISPATCH_BASE", |
| 2770 | i); |
| 2771 | } |
| 2772 | |
Petr Kraus | 9752aae | 2017-11-24 03:05:50 +0100 | [diff] [blame] | 2773 | if (pCreateInfos[i].pRasterizationState) { |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2774 | if (!device_extensions.vk_nv_fill_rectangle) { |
| 2775 | if (pCreateInfos[i].pRasterizationState->polygonMode == VK_POLYGON_MODE_FILL_RECTANGLE_NV) { |
| 2776 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2777 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01414", |
| 2778 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
| 2779 | "pCreateInfos->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_FILL_RECTANGLE_NV " |
| 2780 | "if the extension VK_NV_fill_rectangle is not enabled."); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2781 | } else if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2782 | (physical_device_features.fillModeNonSolid == false)) { |
sfricke-samsung | a44586f | 2020-08-23 22:19:44 -0700 | [diff] [blame] | 2783 | skip |= LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01413", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2784 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2785 | "pCreateInfos[%u]->pRasterizationState->polygonMode cannot be VK_POLYGON_MODE_POINT or " |
| 2786 | "VK_POLYGON_MODE_LINE if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 2787 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2788 | } |
| 2789 | } else { |
| 2790 | if ((pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL) && |
| 2791 | (pCreateInfos[i].pRasterizationState->polygonMode != VK_POLYGON_MODE_FILL_RECTANGLE_NV) && |
| 2792 | (physical_device_features.fillModeNonSolid == false)) { |
| 2793 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2794 | LogError(device, "VUID-VkPipelineRasterizationStateCreateInfo-polygonMode-01507", |
| 2795 | "vkCreateGraphicsPipelines parameter, VkPolygonMode " |
sfricke-samsung | a470e0e | 2020-05-16 00:47:36 -0700 | [diff] [blame] | 2796 | "pCreateInfos[%u]->pRasterizationState->polygonMode must be VK_POLYGON_MODE_FILL or " |
| 2797 | "VK_POLYGON_MODE_FILL_RECTANGLE_NV if VkPhysicalDeviceFeatures->fillModeNonSolid is false.", |
| 2798 | i); |
Chris Mayer | 840b2c4 | 2019-08-22 18:12:22 +0200 | [diff] [blame] | 2799 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2800 | } |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2801 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2802 | if (!has_dynamic_line_width && !physical_device_features.wideLines && |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2803 | (pCreateInfos[i].pRasterizationState->lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2804 | skip |= LogError(device, "VUID-VkGraphicsPipelineCreateInfo-pDynamicStates-00749", |
| 2805 | "The line width state is static (pCreateInfos[%" PRIu32 |
| 2806 | "].pDynamicState->pDynamicStates does not contain VK_DYNAMIC_STATE_LINE_WIDTH) and " |
| 2807 | "VkPhysicalDeviceFeatures::wideLines is disabled, but pCreateInfos[%" PRIu32 |
| 2808 | "].pRasterizationState->lineWidth (=%f) is not 1.0.", |
| 2809 | i, i, pCreateInfos[i].pRasterizationState->lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 2810 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2811 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2812 | } |
| 2813 | } |
| 2814 | |
| 2815 | return skip; |
| 2816 | } |
| 2817 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2818 | bool StatelessValidation::manual_PreCallValidateCreateComputePipelines(VkDevice device, VkPipelineCache pipelineCache, |
| 2819 | uint32_t createInfoCount, |
| 2820 | const VkComputePipelineCreateInfo *pCreateInfos, |
| 2821 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2822 | VkPipeline *pPipelines) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2823 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2824 | for (uint32_t i = 0; i < createInfoCount; i++) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2825 | skip |= validate_string("vkCreateComputePipelines", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2826 | ParameterName("pCreateInfos[%i].stage.pName", ParameterName::IndexVector{i}), |
Mark Lobodzinski | ebee355 | 2018-05-29 09:55:54 -0600 | [diff] [blame] | 2827 | "VUID-VkPipelineShaderStageCreateInfo-pName-parameter", pCreateInfos[i].stage.pName); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2828 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 2829 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != 1)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2830 | skip |= |
| 2831 | LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02669", |
| 2832 | "vkCreateComputePipelines(): in pCreateInfo[%" PRIu32 |
| 2833 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount must equal 1, found %" PRIu32 ".", |
| 2834 | i, feedback_struct->pipelineStageCreationFeedbackCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 2835 | } |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2836 | |
| 2837 | // Make sure compute stage is selected |
| 2838 | if (pCreateInfos[i].stage.stage != VK_SHADER_STAGE_COMPUTE_BIT) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2839 | skip |= LogError(device, "VUID-VkComputePipelineCreateInfo-stage-00701", |
| 2840 | "vkCreateComputePipelines(): the pCreateInfo[%u].stage.stage (%s) is not VK_SHADER_STAGE_COMPUTE_BIT", |
| 2841 | i, string_VkShaderStageFlagBits(pCreateInfos[i].stage.stage)); |
sfricke-samsung | c522715 | 2020-02-09 17:36:31 -0800 | [diff] [blame] | 2842 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 2843 | |
| 2844 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 2845 | skip |= |
| 2846 | LogError(device, "VUID-VkComputePipelineCreateInfo-flags-03370", |
| 2847 | "vkCreateComputePipelines(): flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR"); |
| 2848 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2849 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2850 | return skip; |
| 2851 | } |
| 2852 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2853 | bool StatelessValidation::manual_PreCallValidateCreateSampler(VkDevice device, const VkSamplerCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 2854 | const VkAllocationCallbacks *pAllocator, VkSampler *pSampler) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2855 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2856 | |
| 2857 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2858 | const auto &features = physical_device_features; |
| 2859 | const auto &limits = device_limits; |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2860 | |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2861 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
| 2862 | if (!in_inclusive_range(pCreateInfo->maxAnisotropy, 1.0F, limits.maxSamplerAnisotropy)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2863 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01071", |
| 2864 | "vkCreateSampler(): value of %s must be in range [1.0, %f] %s, but %f found.", |
| 2865 | "pCreateInfo->maxAnisotropy", limits.maxSamplerAnisotropy, |
| 2866 | "VkPhysicalDeviceLimits::maxSamplerAnistropy", pCreateInfo->maxAnisotropy); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2867 | } |
| 2868 | |
| 2869 | // Anistropy cannot be enabled in sampler unless enabled as a feature |
| 2870 | if (features.samplerAnisotropy == VK_FALSE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2871 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-anisotropyEnable-01070", |
| 2872 | "vkCreateSampler(): Anisotropic sampling feature is not enabled, %s must be VK_FALSE.", |
| 2873 | "pCreateInfo->anisotropyEnable"); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2874 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2875 | } |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2876 | |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2877 | if (pCreateInfo->unnormalizedCoordinates == VK_TRUE) { |
| 2878 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2879 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01072", |
| 2880 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2881 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 2882 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2883 | } |
| 2884 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2885 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01073", |
| 2886 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2887 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 2888 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2889 | } |
| 2890 | if (pCreateInfo->minLod != 0.0f || pCreateInfo->maxLod != 0.0f) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2891 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01074", |
| 2892 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2893 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must both be zero.", |
| 2894 | pCreateInfo->minLod, pCreateInfo->maxLod); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2895 | } |
| 2896 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2897 | pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2898 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE && |
| 2899 | pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2900 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01075", |
| 2901 | "vkCreateSampler(): when pCreateInfo->unnormalizedCoordinates is VK_TRUE, " |
| 2902 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must both be " |
| 2903 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER.", |
| 2904 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 2905 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2906 | } |
| 2907 | if (pCreateInfo->anisotropyEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2908 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01076", |
| 2909 | "vkCreateSampler(): pCreateInfo->anisotropyEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2910 | "not both be VK_TRUE."); |
John Zulauf | 7196850 | 2017-10-26 13:51:15 -0600 | [diff] [blame] | 2911 | } |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2912 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2913 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-unnormalizedCoordinates-01077", |
| 2914 | "vkCreateSampler(): pCreateInfo->compareEnable and pCreateInfo->unnormalizedCoordinates must " |
| 2915 | "not both be VK_TRUE."); |
Jesse Hall | cc1fbef | 2018-06-03 15:58:56 -0700 | [diff] [blame] | 2916 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2917 | } |
| 2918 | |
| 2919 | // If compareEnable is VK_TRUE, compareOp must be a valid VkCompareOp value |
| 2920 | if (pCreateInfo->compareEnable == VK_TRUE) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2921 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->compareOp", "VkCompareOp", AllVkCompareOpEnums, |
| 2922 | pCreateInfo->compareOp, "VUID-VkSamplerCreateInfo-compareEnable-01080"); |
sfricke-samsung | 85252fb | 2020-05-08 20:44:06 -0700 | [diff] [blame] | 2923 | const auto *sampler_reduction = lvl_find_in_chain<VkSamplerReductionModeCreateInfo>(pCreateInfo->pNext); |
| 2924 | if (sampler_reduction != nullptr) { |
| 2925 | if (sampler_reduction->reductionMode != VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE) { |
| 2926 | skip |= LogError( |
| 2927 | device, "VUID-VkSamplerCreateInfo-compareEnable-01423", |
| 2928 | "copmareEnable is true so the sampler reduction mode must be VK_SAMPLER_REDUCTION_MODE_WEIGHTED_AVERAGE."); |
| 2929 | } |
| 2930 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2931 | } |
| 2932 | |
| 2933 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER, borderColor must be a |
| 2934 | // valid VkBorderColor value |
| 2935 | if ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2936 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER) || |
| 2937 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 2938 | skip |= validate_ranged_enum("vkCreateSampler", "pCreateInfo->borderColor", "VkBorderColor", AllVkBorderColorEnums, |
| 2939 | pCreateInfo->borderColor, "VUID-VkSamplerCreateInfo-addressModeU-01078"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2940 | } |
| 2941 | |
| 2942 | // If any of addressModeU, addressModeV or addressModeW are VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE, the |
| 2943 | // VK_KHR_sampler_mirror_clamp_to_edge extension must be enabled |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2944 | if (!device_extensions.vk_khr_sampler_mirror_clamp_to_edge && |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2945 | ((pCreateInfo->addressModeU == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2946 | (pCreateInfo->addressModeV == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE) || |
| 2947 | (pCreateInfo->addressModeW == VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE))) { |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 2948 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2949 | LogError(device, "VUID-VkSamplerCreateInfo-addressModeU-01079", |
| 2950 | "vkCreateSampler(): A VkSamplerAddressMode value is set to VK_SAMPLER_ADDRESS_MODE_MIRROR_CLAMP_TO_EDGE " |
| 2951 | "but the VK_KHR_sampler_mirror_clamp_to_edge extension has not been enabled."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 2952 | } |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2953 | |
| 2954 | // Checks for the IMG cubic filtering extension |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 2955 | if (device_extensions.vk_img_filter_cubic) { |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2956 | if ((pCreateInfo->anisotropyEnable == VK_TRUE) && |
| 2957 | ((pCreateInfo->minFilter == VK_FILTER_CUBIC_IMG) || (pCreateInfo->magFilter == VK_FILTER_CUBIC_IMG))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2958 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-magFilter-01081", |
| 2959 | "vkCreateSampler(): Anisotropic sampling must not be VK_TRUE when either minFilter or magFilter " |
| 2960 | "are VK_FILTER_CUBIC_IMG."); |
John Zulauf | 275805c | 2017-10-26 15:34:49 -0600 | [diff] [blame] | 2961 | } |
| 2962 | } |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2963 | |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2964 | // Check for valid Lod range |
| 2965 | if (pCreateInfo->minLod > pCreateInfo->maxLod) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2966 | skip |= |
| 2967 | LogError(device, "VUID-VkSamplerCreateInfo-maxLod-01973", |
| 2968 | "vkCreateSampler(): minLod (%f) is greater than maxLod (%f)", pCreateInfo->minLod, pCreateInfo->maxLod); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2969 | } |
| 2970 | |
| 2971 | // Check mipLodBias to device limit |
| 2972 | if (pCreateInfo->mipLodBias > limits.maxSamplerLodBias) { |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2973 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-mipLodBias-01069", |
| 2974 | "vkCreateSampler(): mipLodBias (%f) is greater than VkPhysicalDeviceLimits::maxSamplerLodBias (%f)", |
| 2975 | pCreateInfo->mipLodBias, limits.maxSamplerLodBias); |
sfricke-samsung | d91da4a | 2020-02-09 17:19:04 -0800 | [diff] [blame] | 2976 | } |
| 2977 | |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2978 | const auto *sampler_conversion = lvl_find_in_chain<VkSamplerYcbcrConversionInfo>(pCreateInfo->pNext); |
| 2979 | if (sampler_conversion != nullptr) { |
| 2980 | if ((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2981 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2982 | (pCreateInfo->addressModeW != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) || |
| 2983 | (pCreateInfo->anisotropyEnable != VK_FALSE) || (pCreateInfo->unnormalizedCoordinates != VK_FALSE)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 2984 | skip |= LogError( |
Mark Lobodzinski | 728ab48 | 2020-02-12 13:46:47 -0700 | [diff] [blame] | 2985 | device, "VUID-VkSamplerCreateInfo-addressModeU-01646", |
Mark Lobodzinski | 61992fc | 2020-01-14 14:00:08 -0700 | [diff] [blame] | 2986 | "vkCreateSampler(): SamplerYCbCrConversion is enabled: " |
| 2987 | "addressModeU (%s), addressModeV (%s), addressModeW (%s) must be CLAMP_TO_EDGE, and anisotropyEnable (%s) " |
| 2988 | "and unnormalizedCoordinates (%s) must be VK_FALSE.", |
| 2989 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), string_VkSamplerAddressMode(pCreateInfo->addressModeV), |
| 2990 | string_VkSamplerAddressMode(pCreateInfo->addressModeW), pCreateInfo->anisotropyEnable ? "VK_TRUE" : "VK_FALSE", |
| 2991 | pCreateInfo->unnormalizedCoordinates ? "VK_TRUE" : "VK_FALSE"); |
| 2992 | } |
| 2993 | } |
janharaldfredriksen-arm | 3b79377 | 2020-05-12 18:55:53 +0200 | [diff] [blame] | 2994 | |
| 2995 | if (pCreateInfo->flags & VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT) { |
| 2996 | if (pCreateInfo->minFilter != pCreateInfo->magFilter) { |
| 2997 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02574", |
| 2998 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 2999 | "pCreateInfo->minFilter (%s) and pCreateInfo->magFilter (%s) must be equal.", |
| 3000 | string_VkFilter(pCreateInfo->minFilter), string_VkFilter(pCreateInfo->magFilter)); |
| 3001 | } |
| 3002 | if (pCreateInfo->mipmapMode != VK_SAMPLER_MIPMAP_MODE_NEAREST) { |
| 3003 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02575", |
| 3004 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3005 | "pCreateInfo->mipmapMode (%s) must be VK_SAMPLER_MIPMAP_MODE_NEAREST.", |
| 3006 | string_VkSamplerMipmapMode(pCreateInfo->mipmapMode)); |
| 3007 | } |
| 3008 | if (pCreateInfo->minLod != 0.0 || pCreateInfo->maxLod != 0.0) { |
| 3009 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02576", |
| 3010 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3011 | "pCreateInfo->minLod (%f) and pCreateInfo->maxLod (%f) must be zero.", |
| 3012 | pCreateInfo->minLod, pCreateInfo->maxLod); |
| 3013 | } |
| 3014 | if (((pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 3015 | (pCreateInfo->addressModeU != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER)) || |
| 3016 | ((pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE) && |
| 3017 | (pCreateInfo->addressModeV != VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER))) { |
| 3018 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02577", |
| 3019 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3020 | "pCreateInfo->addressModeU (%s) and pCreateInfo->addressModeV (%s) must be " |
| 3021 | "VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_EDGE or VK_SAMPLER_ADDRESS_MODE_CLAMP_TO_BORDER", |
| 3022 | string_VkSamplerAddressMode(pCreateInfo->addressModeU), |
| 3023 | string_VkSamplerAddressMode(pCreateInfo->addressModeV)); |
| 3024 | } |
| 3025 | if (pCreateInfo->anisotropyEnable) { |
| 3026 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02578", |
| 3027 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3028 | "pCreateInfo->anisotropyEnable must be VK_FALSE"); |
| 3029 | } |
| 3030 | if (pCreateInfo->compareEnable) { |
| 3031 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02579", |
| 3032 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3033 | "pCreateInfo->compareEnable must be VK_FALSE"); |
| 3034 | } |
| 3035 | if (pCreateInfo->unnormalizedCoordinates) { |
| 3036 | skip |= LogError(device, "VUID-VkSamplerCreateInfo-flags-02580", |
| 3037 | "vkCreateSampler(): when flags includes VK_SAMPLER_CREATE_SUBSAMPLED_BIT_EXT, " |
| 3038 | "pCreateInfo->unnormalizedCoordinates must be VK_FALSE"); |
| 3039 | } |
| 3040 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3041 | } |
| 3042 | |
Tony-LunarG | 7337b31 | 2020-04-15 16:40:25 -0600 | [diff] [blame] | 3043 | if (pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT || |
| 3044 | pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT) { |
| 3045 | if (!device_extensions.vk_ext_custom_border_color) { |
| 3046 | skip |= LogError(device, kVUID_PVError_ExtensionNotEnabled, |
| 3047 | "VkSamplerCreateInfo->borderColor is %s but %s is not enabled.\n", |
| 3048 | string_VkBorderColor(pCreateInfo->borderColor), VK_EXT_CUSTOM_BORDER_COLOR_EXTENSION_NAME); |
| 3049 | } |
| 3050 | auto custom_create_info = lvl_find_in_chain<VkSamplerCustomBorderColorCreateInfoEXT>(pCreateInfo->pNext); |
| 3051 | if (!custom_create_info) { |
| 3052 | skip |= |
| 3053 | LogError(device, "VUID-VkSamplerCreateInfo-borderColor-04011", |
| 3054 | "VkSamplerCreateInfo->borderColor is set to %s but there is no VkSamplerCustomBorderColorCreateInfoEXT " |
| 3055 | "struct in pNext chain.\n", |
| 3056 | string_VkBorderColor(pCreateInfo->borderColor)); |
| 3057 | } else { |
| 3058 | if ((custom_create_info->format != VK_FORMAT_UNDEFINED) && |
| 3059 | ((pCreateInfo->borderColor == VK_BORDER_COLOR_INT_CUSTOM_EXT && !FormatIsSampledInt(custom_create_info->format)) || |
| 3060 | (pCreateInfo->borderColor == VK_BORDER_COLOR_FLOAT_CUSTOM_EXT && |
| 3061 | !FormatIsSampledFloat(custom_create_info->format)))) { |
| 3062 | skip |= LogError(device, "VUID-VkSamplerCustomBorderColorCreateInfoEXT-format-04013", |
| 3063 | "VkSamplerCreateInfo->borderColor is %s but VkSamplerCustomBorderColorCreateInfoEXT.format = %s " |
| 3064 | "whose type does not match\n", |
| 3065 | string_VkBorderColor(pCreateInfo->borderColor), string_VkFormat(custom_create_info->format)); |
| 3066 | ; |
| 3067 | } |
| 3068 | } |
| 3069 | } |
| 3070 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3071 | return skip; |
| 3072 | } |
| 3073 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3074 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorSetLayout(VkDevice device, |
| 3075 | const VkDescriptorSetLayoutCreateInfo *pCreateInfo, |
| 3076 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3077 | VkDescriptorSetLayout *pSetLayout) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3078 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3079 | |
| 3080 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3081 | if ((pCreateInfo != nullptr) && (pCreateInfo->pBindings != nullptr)) { |
| 3082 | for (uint32_t i = 0; i < pCreateInfo->bindingCount; ++i) { |
| 3083 | if (pCreateInfo->pBindings[i].descriptorCount != 0) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3084 | if (((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 3085 | (pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER)) && |
| 3086 | (pCreateInfo->pBindings[i].pImmutableSamplers != nullptr)) { |
| 3087 | for (uint32_t descriptor_index = 0; descriptor_index < pCreateInfo->pBindings[i].descriptorCount; |
| 3088 | ++descriptor_index) { |
| 3089 | if (pCreateInfo->pBindings[i].pImmutableSamplers[descriptor_index] == VK_NULL_HANDLE) { |
Spencer Fricke | b0e3082 | 2020-03-23 10:32:30 -0700 | [diff] [blame] | 3090 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-00282", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3091 | "vkCreateDescriptorSetLayout: required parameter " |
| 3092 | "pCreateInfo->pBindings[%d].pImmutableSamplers[%d] specified as VK_NULL_HANDLE", |
| 3093 | i, descriptor_index); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3094 | } |
| 3095 | } |
| 3096 | } |
| 3097 | |
| 3098 | // If descriptorCount is not 0, stageFlags must be a valid combination of VkShaderStageFlagBits values |
| 3099 | if ((pCreateInfo->pBindings[i].stageFlags != 0) && |
| 3100 | ((pCreateInfo->pBindings[i].stageFlags & (~AllVkShaderStageFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3101 | skip |= LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorCount-00283", |
| 3102 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0, " |
| 3103 | "pCreateInfo->pBindings[%d].stageFlags must be a valid combination of VkShaderStageFlagBits " |
| 3104 | "values.", |
| 3105 | i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3106 | } |
Spencer Fricke | 84d0cc0 | 2020-03-16 17:21:59 -0700 | [diff] [blame] | 3107 | |
| 3108 | if ((pCreateInfo->pBindings[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT) && |
| 3109 | (pCreateInfo->pBindings[i].stageFlags != 0) && |
| 3110 | (pCreateInfo->pBindings[i].stageFlags != VK_SHADER_STAGE_FRAGMENT_BIT)) { |
| 3111 | skip |= |
| 3112 | LogError(device, "VUID-VkDescriptorSetLayoutBinding-descriptorType-01510", |
| 3113 | "vkCreateDescriptorSetLayout(): if pCreateInfo->pBindings[%d].descriptorCount is not 0 and " |
| 3114 | "descriptorType is VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT then pCreateInfo->pBindings[%d].stageFlags " |
| 3115 | "must be 0 or VK_SHADER_STAGE_FRAGMENT_BIT but is currently %s", |
| 3116 | i, i, string_VkShaderStageFlags(pCreateInfo->pBindings[i].stageFlags).c_str()); |
| 3117 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3118 | } |
| 3119 | } |
| 3120 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3121 | return skip; |
| 3122 | } |
| 3123 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3124 | bool StatelessValidation::manual_PreCallValidateFreeDescriptorSets(VkDevice device, VkDescriptorPool descriptorPool, |
| 3125 | uint32_t descriptorSetCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3126 | const VkDescriptorSet *pDescriptorSets) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3127 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3128 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 3129 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3130 | return validate_array("vkFreeDescriptorSets", "descriptorSetCount", "pDescriptorSets", descriptorSetCount, &pDescriptorSets, |
| 3131 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3132 | } |
| 3133 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3134 | bool StatelessValidation::validate_WriteDescriptorSet(const char *vkCallingFunction, const uint32_t descriptorWriteCount, |
| 3135 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 3136 | const bool validateDstSet) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3137 | bool skip = false; |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3138 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3139 | if (pDescriptorWrites != NULL) { |
| 3140 | for (uint32_t i = 0; i < descriptorWriteCount; ++i) { |
| 3141 | // descriptorCount must be greater than 0 |
| 3142 | if (pDescriptorWrites[i].descriptorCount == 0) { |
| 3143 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3144 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorCount-arraylength", |
| 3145 | "%s(): parameter pDescriptorWrites[%d].descriptorCount must be greater than 0.", vkCallingFunction, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3146 | } |
| 3147 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3148 | // If called from vkCmdPushDescriptorSetKHR, the dstSet member is ignored. |
| 3149 | if (validateDstSet) { |
| 3150 | // dstSet must be a valid VkDescriptorSet handle |
| 3151 | skip |= validate_required_handle(vkCallingFunction, |
| 3152 | ParameterName("pDescriptorWrites[%i].dstSet", ParameterName::IndexVector{i}), |
| 3153 | pDescriptorWrites[i].dstSet); |
| 3154 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3155 | |
| 3156 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLER) || |
| 3157 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER) || |
| 3158 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE) || |
| 3159 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_IMAGE) || |
| 3160 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT)) { |
| 3161 | // If descriptorType is VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, |
| 3162 | // VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3163 | // pImageInfo must be a pointer to an array of descriptorCount valid VkDescriptorImageInfo structures. |
| 3164 | // Valid imageView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3165 | if (pDescriptorWrites[i].pImageInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3166 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00322", |
| 3167 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 3168 | "VK_DESCRIPTOR_TYPE_SAMPLER, VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, " |
| 3169 | "VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or " |
| 3170 | "VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, pDescriptorWrites[%d].pImageInfo must not be NULL.", |
| 3171 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3172 | } else if (pDescriptorWrites[i].descriptorType != VK_DESCRIPTOR_TYPE_SAMPLER) { |
| 3173 | // If descriptorType is VK_DESCRIPTOR_TYPE_COMBINED_IMAGE_SAMPLER, VK_DESCRIPTOR_TYPE_SAMPLED_IMAGE, |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3174 | // VK_DESCRIPTOR_TYPE_STORAGE_IMAGE or VK_DESCRIPTOR_TYPE_INPUT_ATTACHMENT, the imageLayout |
| 3175 | // member of any given element of pImageInfo must be a valid VkImageLayout |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3176 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 3177 | ++descriptor_index) { |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3178 | skip |= validate_ranged_enum(vkCallingFunction, |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3179 | ParameterName("pDescriptorWrites[%i].pImageInfo[%i].imageLayout", |
| 3180 | ParameterName::IndexVector{i, descriptor_index}), |
| 3181 | "VkImageLayout", AllVkImageLayoutEnums, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3182 | pDescriptorWrites[i].pImageInfo[descriptor_index].imageLayout, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3183 | } |
| 3184 | } |
| 3185 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 3186 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 3187 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC) || |
| 3188 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
| 3189 | // If descriptorType is VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, |
| 3190 | // VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, pBufferInfo must be a |
| 3191 | // pointer to an array of descriptorCount valid VkDescriptorBufferInfo structures |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3192 | // Valid buffer handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3193 | if (pDescriptorWrites[i].pBufferInfo == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3194 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00324", |
| 3195 | "%s(): if pDescriptorWrites[%d].descriptorType is " |
| 3196 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER, VK_DESCRIPTOR_TYPE_STORAGE_BUFFER, " |
| 3197 | "VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC or VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC, " |
| 3198 | "pDescriptorWrites[%d].pBufferInfo must not be NULL.", |
| 3199 | vkCallingFunction, i, i); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3200 | } else { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3201 | const auto *robustness2_features = |
| 3202 | lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 3203 | if (robustness2_features && robustness2_features->nullDescriptor) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3204 | for (uint32_t descriptor_index = 0; descriptor_index < pDescriptorWrites[i].descriptorCount; |
| 3205 | ++descriptor_index) { |
| 3206 | if (pDescriptorWrites[i].pBufferInfo[descriptor_index].buffer == VK_NULL_HANDLE && |
| 3207 | (pDescriptorWrites[i].pBufferInfo[descriptor_index].offset != 0 || |
| 3208 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range != VK_WHOLE_SIZE)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3209 | skip |= LogError(device, "VUID-VkDescriptorBufferInfo-buffer-02999", |
| 3210 | "%s(): if pDescriptorWrites[%d].buffer is VK_NULL_HANDLE, " |
baldurk | 751594b | 2020-09-09 09:41:02 +0100 | [diff] [blame] | 3211 | "offset (%" PRIu64 ") must be zero and range (%" PRIu64 ") must be VK_WHOLE_SIZE.", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3212 | vkCallingFunction, i, pDescriptorWrites[i].pBufferInfo[descriptor_index].offset, |
| 3213 | pDescriptorWrites[i].pBufferInfo[descriptor_index].range); |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3214 | } |
| 3215 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3216 | } |
| 3217 | } |
| 3218 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_TEXEL_BUFFER) || |
| 3219 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_TEXEL_BUFFER)) { |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 3220 | // Valid bufferView handles are checked in ObjectLifetimes::ValidateDescriptorWrite. |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3221 | } |
| 3222 | |
| 3223 | if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER) || |
| 3224 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_UNIFORM_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3225 | VkDeviceSize uniform_alignment = device_limits.minUniformBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3226 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 3227 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3228 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3229 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3230 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00327", |
| 3231 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 3232 | ") must be a multiple of device limit minUniformBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3233 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, uniform_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3234 | } |
| 3235 | } |
| 3236 | } |
| 3237 | } else if ((pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER) || |
| 3238 | (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_STORAGE_BUFFER_DYNAMIC)) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3239 | VkDeviceSize storage_alignment = device_limits.minStorageBufferOffsetAlignment; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3240 | for (uint32_t j = 0; j < pDescriptorWrites[i].descriptorCount; j++) { |
| 3241 | if (pDescriptorWrites[i].pBufferInfo != NULL) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3242 | if (SafeModulo(pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment) != 0) { |
Mark Lobodzinski | 8852949 | 2018-04-01 10:38:15 -0600 | [diff] [blame] | 3243 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3244 | LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-00328", |
| 3245 | "%s(): pDescriptorWrites[%d].pBufferInfo[%d].offset (0x%" PRIxLEAST64 |
| 3246 | ") must be a multiple of device limit minStorageBufferOffsetAlignment 0x%" PRIxLEAST64 ".", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3247 | vkCallingFunction, i, j, pDescriptorWrites[i].pBufferInfo[j].offset, storage_alignment); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3248 | } |
| 3249 | } |
| 3250 | } |
| 3251 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3252 | // pNext chain must be either NULL or a pointer to a valid instance of VkWriteDescriptorSetAccelerationStructureKHR |
| 3253 | // or VkWriteDescriptorSetInlineUniformBlockEX |
| 3254 | if (pDescriptorWrites[i].pNext) { |
| 3255 | if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR) { |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3256 | const auto *pnext_struct = |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3257 | lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureKHR>(pDescriptorWrites[i].pNext); |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3258 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3259 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-02382", |
| 3260 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_KHR, the pNext" |
| 3261 | "chain must include a VkWriteDescriptorSetAccelerationStructureKHR structure whose " |
| 3262 | "accelerationStructureCount %d member equals descriptorCount %d.", |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3263 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3264 | pDescriptorWrites[i].descriptorCount); |
| 3265 | } |
| 3266 | // further checks only if we have right structtype |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3267 | if (pnext_struct) { |
| 3268 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3269 | skip |= LogError( |
| 3270 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-02236", |
| 3271 | "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure " |
| 3272 | ".", |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3273 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3274 | } |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 3275 | if (pnext_struct->accelerationStructureCount == 0) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3276 | skip |= LogError( |
| 3277 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-accelerationStructureCount-arraylength", |
| 3278 | "%s(): accelerationStructureCount must be greater than 0 ."); |
| 3279 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 3280 | const auto *robustness2_features = |
| 3281 | lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 3282 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 3283 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 3284 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 3285 | skip |= LogError( |
| 3286 | device, "VUID-VkWriteDescriptorSetAccelerationStructureKHR-pAccelerationStructures-03580", |
| 3287 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
| 3288 | "pAccelerationStructures must not be VK_NULL_HANDLE."); |
| 3289 | } |
| 3290 | } |
| 3291 | } |
| 3292 | } |
| 3293 | } else if (pDescriptorWrites[i].descriptorType == VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV) { |
| 3294 | const auto *pnext_struct = |
| 3295 | lvl_find_in_chain<VkWriteDescriptorSetAccelerationStructureNV>(pDescriptorWrites[i].pNext); |
| 3296 | if (!pnext_struct || (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount)) { |
| 3297 | skip |= LogError(device, "VUID-VkWriteDescriptorSet-descriptorType-03817", |
| 3298 | "%s(): If descriptorType is VK_DESCRIPTOR_TYPE_ACCELERATION_STRUCTURE_NV, the pNext" |
| 3299 | "chain must include a VkWriteDescriptorSetAccelerationStructureNV structure whose " |
| 3300 | "accelerationStructureCount %d member equals descriptorCount %d.", |
| 3301 | vkCallingFunction, pnext_struct ? pnext_struct->accelerationStructureCount : -1, |
| 3302 | pDescriptorWrites[i].descriptorCount); |
| 3303 | } |
| 3304 | // further checks only if we have right structtype |
| 3305 | if (pnext_struct) { |
| 3306 | if (pnext_struct->accelerationStructureCount != pDescriptorWrites[i].descriptorCount) { |
| 3307 | skip |= LogError( |
| 3308 | device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-03747", |
| 3309 | "%s(): accelerationStructureCount %d must be equal to descriptorCount %d in the extended structure " |
| 3310 | ".", |
| 3311 | vkCallingFunction, pnext_struct->accelerationStructureCount, pDescriptorWrites[i].descriptorCount); |
| 3312 | } |
| 3313 | if (pnext_struct->accelerationStructureCount == 0) { |
| 3314 | skip |= LogError( |
| 3315 | device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-accelerationStructureCount-arraylength", |
| 3316 | "%s(): accelerationStructureCount must be greater than 0 ."); |
| 3317 | } |
| 3318 | const auto *robustness2_features = |
| 3319 | lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 3320 | if (robustness2_features && robustness2_features->nullDescriptor == VK_FALSE) { |
| 3321 | for (uint32_t j = 0; j < pnext_struct->accelerationStructureCount; ++j) { |
| 3322 | if (pnext_struct->pAccelerationStructures[j] == VK_NULL_HANDLE) { |
| 3323 | skip |= LogError( |
| 3324 | device, "VUID-VkWriteDescriptorSetAccelerationStructureNV-pAccelerationStructures-03749", |
| 3325 | "%s(): If the nullDescriptor feature is not enabled, each member of " |
| 3326 | "pAccelerationStructures must not be VK_NULL_HANDLE."); |
| 3327 | } |
| 3328 | } |
| 3329 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 3330 | } |
| 3331 | } |
| 3332 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3333 | } |
| 3334 | } |
| 3335 | return skip; |
| 3336 | } |
| 3337 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 3338 | bool StatelessValidation::manual_PreCallValidateUpdateDescriptorSets(VkDevice device, uint32_t descriptorWriteCount, |
| 3339 | const VkWriteDescriptorSet *pDescriptorWrites, |
| 3340 | uint32_t descriptorCopyCount, |
| 3341 | const VkCopyDescriptorSet *pDescriptorCopies) const { |
| 3342 | return validate_WriteDescriptorSet("vkUpdateDescriptorSets", descriptorWriteCount, pDescriptorWrites); |
| 3343 | } |
| 3344 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3345 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3346 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3347 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3348 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_1); |
| 3349 | } |
| 3350 | |
sfricke-samsung | 681ab7b | 2020-10-29 01:53:35 -0700 | [diff] [blame] | 3351 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
| 3352 | const VkAllocationCallbacks *pAllocator, |
| 3353 | VkRenderPass *pRenderPass) const { |
| 3354 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 3355 | } |
| 3356 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3357 | bool StatelessValidation::manual_PreCallValidateCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3358 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3359 | VkRenderPass *pRenderPass) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3360 | return CreateRenderPassGeneric(device, pCreateInfo, pAllocator, pRenderPass, RENDER_PASS_VERSION_2); |
| 3361 | } |
| 3362 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3363 | bool StatelessValidation::manual_PreCallValidateFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, |
| 3364 | uint32_t commandBufferCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3365 | const VkCommandBuffer *pCommandBuffers) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3366 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3367 | |
| 3368 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3369 | // This is an array of handles, where the elements are allowed to be VK_NULL_HANDLE, and does not require any validation beyond |
| 3370 | // validate_array() |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3371 | skip |= validate_array("vkFreeCommandBuffers", "commandBufferCount", "pCommandBuffers", commandBufferCount, &pCommandBuffers, |
| 3372 | true, true, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3373 | return skip; |
| 3374 | } |
| 3375 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3376 | bool StatelessValidation::manual_PreCallValidateBeginCommandBuffer(VkCommandBuffer commandBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3377 | const VkCommandBufferBeginInfo *pBeginInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3378 | bool skip = false; |
Petr Kraus | e7bb9e8 | 2019-08-11 21:34:43 +0200 | [diff] [blame] | 3379 | |
| 3380 | // VkCommandBufferInheritanceInfo validation, due to a 'noautovalidity' of pBeginInfo->pInheritanceInfo in vkBeginCommandBuffer |
| 3381 | const char *cmd_name = "vkBeginCommandBuffer"; |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame^] | 3382 | bool cb_is_secondary; |
| 3383 | { |
| 3384 | auto lock = cb_read_lock(); |
| 3385 | cb_is_secondary = (secondary_cb_map.find(commandBuffer) != secondary_cb_map.end()); |
| 3386 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3387 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame^] | 3388 | if (cb_is_secondary) { |
| 3389 | // Implicit VUs |
| 3390 | // validate only sType here; pointer has to be validated in core_validation |
| 3391 | const bool k_not_required = false; |
| 3392 | const char *k_no_vuid = nullptr; |
| 3393 | const VkCommandBufferInheritanceInfo *info = pBeginInfo->pInheritanceInfo; |
| 3394 | skip |= validate_struct_type(cmd_name, "pBeginInfo->pInheritanceInfo", "VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO", |
| 3395 | info, VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_INFO, k_not_required, k_no_vuid, |
| 3396 | "VUID-VkCommandBufferInheritanceInfo-sType-sType"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3397 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame^] | 3398 | if (info) { |
| 3399 | const VkStructureType allowed_structs_vk_command_buffer_inheritance_info[] = { |
| 3400 | VK_STRUCTURE_TYPE_COMMAND_BUFFER_INHERITANCE_CONDITIONAL_RENDERING_INFO_EXT }; |
| 3401 | skip |= validate_struct_pnext( |
| 3402 | cmd_name, "pBeginInfo->pInheritanceInfo->pNext", "VkCommandBufferInheritanceConditionalRenderingInfoEXT", info->pNext, |
| 3403 | ARRAY_SIZE(allowed_structs_vk_command_buffer_inheritance_info), allowed_structs_vk_command_buffer_inheritance_info, |
| 3404 | GeneratedVulkanHeaderVersion, "VUID-VkCommandBufferInheritanceInfo-pNext-pNext", |
| 3405 | "VUID-VkCommandBufferInheritanceInfo-sType-unique"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3406 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame^] | 3407 | skip |= validate_bool32(cmd_name, "pBeginInfo->pInheritanceInfo->occlusionQueryEnable", info->occlusionQueryEnable); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3408 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame^] | 3409 | // Explicit VUs |
| 3410 | if (!physical_device_features.inheritedQueries && info->occlusionQueryEnable == VK_TRUE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3411 | skip |= LogError( |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame^] | 3412 | commandBuffer, "VUID-VkCommandBufferInheritanceInfo-occlusionQueryEnable-00056", |
| 3413 | "%s: Inherited queries feature is disabled, but pBeginInfo->pInheritanceInfo->occlusionQueryEnable is VK_TRUE.", |
| 3414 | cmd_name); |
| 3415 | } |
| 3416 | |
| 3417 | if (physical_device_features.inheritedQueries) { |
| 3418 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", "VkQueryControlFlagBits", |
| 3419 | AllVkQueryControlFlagBits, info->queryFlags, kOptionalFlags, |
| 3420 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-00057"); |
| 3421 | } |
| 3422 | else { // !inheritedQueries |
| 3423 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->queryFlags", info->queryFlags, |
| 3424 | "VUID-VkCommandBufferInheritanceInfo-queryFlags-02788"); |
| 3425 | } |
| 3426 | |
| 3427 | if (physical_device_features.pipelineStatisticsQuery) { |
| 3428 | skip |= validate_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", "VkQueryPipelineStatisticFlagBits", |
| 3429 | AllVkQueryPipelineStatisticFlagBits, info->pipelineStatistics, kOptionalFlags, |
| 3430 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-02789"); |
| 3431 | } |
| 3432 | else { // !pipelineStatisticsQuery |
| 3433 | skip |= validate_reserved_flags(cmd_name, "pBeginInfo->pInheritanceInfo->pipelineStatistics", info->pipelineStatistics, |
| 3434 | "VUID-VkCommandBufferInheritanceInfo-pipelineStatistics-00058"); |
| 3435 | } |
| 3436 | |
| 3437 | const auto *conditional_rendering = lvl_find_in_chain<VkCommandBufferInheritanceConditionalRenderingInfoEXT>(info->pNext); |
| 3438 | if (conditional_rendering) { |
| 3439 | const auto *cr_features = lvl_find_in_chain<VkPhysicalDeviceConditionalRenderingFeaturesEXT>(device_createinfo_pnext); |
| 3440 | const auto inherited_conditional_rendering = cr_features && cr_features->inheritedConditionalRendering; |
| 3441 | if (!inherited_conditional_rendering && conditional_rendering->conditionalRenderingEnable == VK_TRUE) { |
| 3442 | skip |= LogError( |
| 3443 | commandBuffer, "VUID-VkCommandBufferInheritanceConditionalRenderingInfoEXT-conditionalRenderingEnable-01977", |
| 3444 | "vkBeginCommandBuffer: Inherited conditional rendering is disabled, but " |
| 3445 | "pBeginInfo->pInheritanceInfo->pNext<VkCommandBufferInheritanceConditionalRenderingInfoEXT> is VK_TRUE."); |
| 3446 | } |
Petr Kraus | 139757b | 2019-08-15 17:19:33 +0200 | [diff] [blame] | 3447 | } |
| 3448 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3449 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3450 | return skip; |
| 3451 | } |
| 3452 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3453 | bool StatelessValidation::manual_PreCallValidateCmdSetViewport(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3454 | uint32_t viewportCount, const VkViewport *pViewports) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3455 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3456 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3457 | if (!physical_device_features.multiViewport) { |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3458 | if (firstViewport != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3459 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01224", |
| 3460 | "vkCmdSetViewport: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 ") is not 0.", |
| 3461 | firstViewport); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3462 | } |
| 3463 | if (viewportCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3464 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-viewportCount-01225", |
| 3465 | "vkCmdSetViewport: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 ") is not 1.", |
| 3466 | viewportCount); |
Petr Kraus | d55e77c | 2018-01-09 22:09:25 +0100 | [diff] [blame] | 3467 | } |
| 3468 | } else { // multiViewport enabled |
Petr Kraus | 7dfeed1 | 2018-02-27 20:51:20 +0100 | [diff] [blame] | 3469 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3470 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3471 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewport-firstViewport-01223", |
| 3472 | "vkCmdSetViewport: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3473 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3474 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3475 | } |
| 3476 | } |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3477 | |
| 3478 | if (pViewports) { |
| 3479 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 3480 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
Jeff Bolz | 6d3beaa | 2019-02-09 21:00:05 -0600 | [diff] [blame] | 3481 | const char *fn_name = "vkCmdSetViewport"; |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3482 | skip |= manual_PreCallValidateViewport( |
| 3483 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
Petr Kraus | b3fcdb4 | 2018-01-09 22:09:09 +0100 | [diff] [blame] | 3484 | } |
| 3485 | } |
| 3486 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3487 | return skip; |
| 3488 | } |
| 3489 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3490 | bool StatelessValidation::manual_PreCallValidateCmdSetScissor(VkCommandBuffer commandBuffer, uint32_t firstScissor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3491 | uint32_t scissorCount, const VkRect2D *pScissors) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3492 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3493 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3494 | if (!physical_device_features.multiViewport) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3495 | if (firstScissor != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3496 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00593", |
| 3497 | "vkCmdSetScissor: The multiViewport feature is disabled, but firstScissor (=%" PRIu32 ") is not 0.", |
| 3498 | firstScissor); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3499 | } |
| 3500 | if (scissorCount > 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3501 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-scissorCount-00594", |
| 3502 | "vkCmdSetScissor: The multiViewport feature is disabled, but scissorCount (=%" PRIu32 ") is not 1.", |
| 3503 | scissorCount); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3504 | } |
| 3505 | } else { // multiViewport enabled |
| 3506 | const uint64_t sum = static_cast<uint64_t>(firstScissor) + static_cast<uint64_t>(scissorCount); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3507 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3508 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-firstScissor-00592", |
| 3509 | "vkCmdSetScissor: firstScissor + scissorCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 3510 | ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 3511 | firstScissor, scissorCount, sum, device_limits.maxViewports); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3512 | } |
| 3513 | } |
| 3514 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3515 | if (pScissors) { |
| 3516 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 3517 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3518 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3519 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3520 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 3521 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 3522 | scissor.offset.x); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3523 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3524 | |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3525 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3526 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-x-00595", |
| 3527 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 3528 | scissor.offset.y); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3529 | } |
| 3530 | |
| 3531 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 3532 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3533 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00596", |
| 3534 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3535 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3536 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3537 | } |
| 3538 | |
| 3539 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 3540 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3541 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissor-offset-00597", |
| 3542 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 3543 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 3544 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3545 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3546 | } |
| 3547 | } |
Petr Kraus | 6260f0a | 2018-02-27 21:15:55 +0100 | [diff] [blame] | 3548 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3549 | return skip; |
| 3550 | } |
| 3551 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3552 | bool StatelessValidation::manual_PreCallValidateCmdSetLineWidth(VkCommandBuffer commandBuffer, float lineWidth) const { |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3553 | bool skip = false; |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3554 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3555 | if (!physical_device_features.wideLines && (lineWidth != 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3556 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineWidth-lineWidth-00788", |
| 3557 | "VkPhysicalDeviceFeatures::wideLines is disabled, but lineWidth (=%f) is not 1.0.", lineWidth); |
Petr Kraus | 299ba62 | 2017-11-24 03:09:03 +0100 | [diff] [blame] | 3558 | } |
| 3559 | |
| 3560 | return skip; |
| 3561 | } |
| 3562 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3563 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, VkDeviceSize offset, |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3564 | uint32_t drawCount, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3565 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3566 | |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3567 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 41ce65b | 2020-10-30 12:17:06 -0600 | [diff] [blame] | 3568 | skip |= LogError(device, "VUID-vkCmdDrawIndirect-drawCount-02718", |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3569 | "CmdDrawIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount); |
| 3570 | } |
| 3571 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 3572 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirect-drawCount-02719", |
| 3573 | "CmdDrawIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount, |
| 3574 | device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3575 | } |
| 3576 | return skip; |
| 3577 | } |
| 3578 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3579 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3580 | VkDeviceSize offset, uint32_t drawCount, uint32_t stride) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3581 | bool skip = false; |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3582 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3583 | skip |= |
Mark Lobodzinski | 41ce65b | 2020-10-30 12:17:06 -0600 | [diff] [blame] | 3584 | LogError(device, "VUID-vkCmdDrawIndexedIndirect-drawCount-02718", |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 3585 | "CmdDrawIndexedIndirect(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount); |
| 3586 | } |
| 3587 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 3588 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirect-drawCount-02719", |
| 3589 | "CmdDrawIndexedIndirect(): drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount, |
| 3590 | device_limits.maxDrawIndirectCount); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3591 | } |
| 3592 | return skip; |
| 3593 | } |
| 3594 | |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3595 | bool StatelessValidation::ValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 3596 | VkDeviceSize countBufferOffset, bool khr) const { |
| 3597 | bool skip = false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3598 | const char *api_name = khr ? "vkCmdDrawIndirectCountKHR()" : "vkCmdDrawIndirectCount()"; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3599 | if (offset & 3) { |
| 3600 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-offset-02710", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3601 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3602 | } |
| 3603 | |
| 3604 | if (countBufferOffset & 3) { |
| 3605 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndirectCount-countBufferOffset-02716", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3606 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3607 | countBufferOffset); |
| 3608 | } |
| 3609 | return skip; |
| 3610 | } |
| 3611 | |
| 3612 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3613 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3614 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3615 | uint32_t stride) const { |
| 3616 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 3617 | } |
| 3618 | |
| 3619 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3620 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3621 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3622 | uint32_t stride) const { |
| 3623 | return ValidateCmdDrawIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 3624 | } |
| 3625 | |
| 3626 | bool StatelessValidation::ValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkDeviceSize offset, |
| 3627 | VkDeviceSize countBufferOffset, bool khr) const { |
| 3628 | bool skip = false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3629 | const char *api_name = khr ? "vkCmdDrawIndexedIndirectCountKHR()" : "vkCmdDrawIndexedIndirectCount()"; |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3630 | if (offset & 3) { |
| 3631 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-offset-02710", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3632 | "%s: parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, offset); |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3633 | } |
| 3634 | |
| 3635 | if (countBufferOffset & 3) { |
| 3636 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawIndexedIndirectCount-countBufferOffset-02716", |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 3637 | "%s: parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", api_name, |
sfricke-samsung | f692b97 | 2020-05-02 08:00:45 -0700 | [diff] [blame] | 3638 | countBufferOffset); |
| 3639 | } |
| 3640 | return skip; |
| 3641 | } |
| 3642 | |
| 3643 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCount(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3644 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3645 | VkDeviceSize countBufferOffset, uint32_t maxDrawCount, |
| 3646 | uint32_t stride) const { |
| 3647 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, false); |
| 3648 | } |
| 3649 | |
| 3650 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndexedIndirectCountKHR(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 3651 | VkDeviceSize offset, VkBuffer countBuffer, |
| 3652 | VkDeviceSize countBufferOffset, |
| 3653 | uint32_t maxDrawCount, uint32_t stride) const { |
| 3654 | return ValidateCmdDrawIndexedIndirectCount(commandBuffer, offset, countBufferOffset, true); |
| 3655 | } |
| 3656 | |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3657 | bool StatelessValidation::manual_PreCallValidateCmdClearAttachments(VkCommandBuffer commandBuffer, uint32_t attachmentCount, |
| 3658 | const VkClearAttachment *pAttachments, uint32_t rectCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3659 | const VkClearRect *pRects) const { |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3660 | bool skip = false; |
| 3661 | for (uint32_t rect = 0; rect < rectCount; rect++) { |
| 3662 | if (pRects[rect].layerCount == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3663 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-layerCount-01934", |
| 3664 | "CmdClearAttachments(): pRects[%d].layerCount is zero.", rect); |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3665 | } |
sfricke-samsung | 1086768 | 2020-04-25 02:20:39 -0700 | [diff] [blame] | 3666 | if (pRects[rect].rect.extent.width == 0) { |
| 3667 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02682", |
| 3668 | "CmdClearAttachments(): pRects[%d].rect.extent.width is zero.", rect); |
| 3669 | } |
| 3670 | if (pRects[rect].rect.extent.height == 0) { |
| 3671 | skip |= LogError(commandBuffer, "VUID-vkCmdClearAttachments-rect-02683", |
| 3672 | "CmdClearAttachments(): pRects[%d].rect.extent.height is zero.", rect); |
| 3673 | } |
Mark Lobodzinski | f77a4ac | 2019-06-27 15:30:51 -0600 | [diff] [blame] | 3674 | } |
| 3675 | return skip; |
| 3676 | } |
| 3677 | |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3678 | bool StatelessValidation::ValidateGetPhysicalDeviceImageFormatProperties2(VkPhysicalDevice physicalDevice, |
| 3679 | const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3680 | VkImageFormatProperties2 *pImageFormatProperties, |
| 3681 | const char *apiName) const { |
| 3682 | bool skip = false; |
| 3683 | |
| 3684 | if (pImageFormatInfo != nullptr) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 3685 | const auto image_stencil_struct = lvl_find_in_chain<VkImageStencilUsageCreateInfo>(pImageFormatInfo->pNext); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3686 | if (image_stencil_struct != nullptr) { |
| 3687 | if ((image_stencil_struct->stencilUsage & VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT) != 0) { |
| 3688 | VkImageUsageFlags legal_flags = (VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT | VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT); |
| 3689 | // No flags other than the legal attachment bits may be set |
| 3690 | legal_flags |= VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT; |
| 3691 | if ((image_stencil_struct->stencilUsage & ~legal_flags) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3692 | skip |= LogError(physicalDevice, "VUID-VkImageStencilUsageCreateInfo-stencilUsage-02539", |
| 3693 | "%s(): in pNext chain, VkImageStencilUsageCreateInfo::stencilUsage " |
| 3694 | "includes VK_IMAGE_USAGE_TRANSIENT_ATTACHMENT_BIT, it must not include bits other than " |
| 3695 | "VK_IMAGE_USAGE_DEPTH_STENCIL_ATTACHMENT_BIT or VK_IMAGE_USAGE_INPUT_ATTACHMENT_BIT", |
| 3696 | apiName); |
Andrew Fobel | 3abeb99 | 2020-01-20 16:33:22 -0500 | [diff] [blame] | 3697 | } |
| 3698 | } |
| 3699 | } |
| 3700 | } |
| 3701 | |
| 3702 | return skip; |
| 3703 | } |
| 3704 | |
| 3705 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2( |
| 3706 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3707 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 3708 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 3709 | "vkGetPhysicalDeviceImageFormatProperties2"); |
| 3710 | } |
| 3711 | |
| 3712 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties2KHR( |
| 3713 | VkPhysicalDevice physicalDevice, const VkPhysicalDeviceImageFormatInfo2 *pImageFormatInfo, |
| 3714 | VkImageFormatProperties2 *pImageFormatProperties) const { |
| 3715 | return ValidateGetPhysicalDeviceImageFormatProperties2(physicalDevice, pImageFormatInfo, pImageFormatProperties, |
| 3716 | "vkGetPhysicalDeviceImageFormatProperties2KHR"); |
| 3717 | } |
| 3718 | |
Lionel Landwerlin | 5fe5275 | 2020-07-22 08:18:14 +0300 | [diff] [blame] | 3719 | bool StatelessValidation::manual_PreCallValidateGetPhysicalDeviceImageFormatProperties( |
| 3720 | VkPhysicalDevice physicalDevice, VkFormat format, VkImageType type, VkImageTiling tiling, VkImageUsageFlags usage, |
| 3721 | VkImageCreateFlags flags, VkImageFormatProperties *pImageFormatProperties) const { |
| 3722 | bool skip = false; |
| 3723 | |
| 3724 | if (tiling == VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT) { |
| 3725 | skip |= LogError(physicalDevice, "VUID-vkGetPhysicalDeviceImageFormatProperties-tiling-02248", |
| 3726 | "vkGetPhysicalDeviceImageFormatProperties(): tiling must not be VK_IMAGE_TILING_DRM_FORMAT_MODIFIER_EXT."); |
| 3727 | } |
| 3728 | |
| 3729 | return skip; |
| 3730 | } |
| 3731 | |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 3732 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer(VkCommandBuffer commandBuffer, VkBuffer srcBuffer, VkBuffer dstBuffer, |
| 3733 | uint32_t regionCount, const VkBufferCopy *pRegions) const { |
| 3734 | bool skip = false; |
| 3735 | |
| 3736 | if (pRegions != nullptr) { |
| 3737 | for (uint32_t i = 0; i < regionCount; i++) { |
| 3738 | if (pRegions[i].size == 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3739 | skip |= LogError(device, "VUID-VkBufferCopy-size-01988", |
| 3740 | "vkCmdCopyBuffer() pRegions[%u].size must be greater than zero", i); |
sfricke-samsung | 3999ef6 | 2020-02-09 17:05:59 -0800 | [diff] [blame] | 3741 | } |
| 3742 | } |
| 3743 | } |
| 3744 | return skip; |
| 3745 | } |
| 3746 | |
Jeff Leger | 178b1e5 | 2020-10-05 12:22:23 -0400 | [diff] [blame] | 3747 | bool StatelessValidation::manual_PreCallValidateCmdCopyBuffer2KHR(VkCommandBuffer commandBuffer, |
| 3748 | const VkCopyBufferInfo2KHR *pCopyBufferInfo) const { |
| 3749 | bool skip = false; |
| 3750 | |
| 3751 | if (pCopyBufferInfo->pRegions != nullptr) { |
| 3752 | for (uint32_t i = 0; i < pCopyBufferInfo->regionCount; i++) { |
| 3753 | if (pCopyBufferInfo->pRegions[i].size == 0) { |
| 3754 | skip |= LogError(device, "VUID-VkBufferCopy2KHR-size-01988", |
| 3755 | "vkCmdCopyBuffer2KHR() pCopyBufferInfo->pRegions[%u].size must be greater than zero", i); |
| 3756 | } |
| 3757 | } |
| 3758 | } |
| 3759 | return skip; |
| 3760 | } |
| 3761 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3762 | bool StatelessValidation::manual_PreCallValidateCmdUpdateBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3763 | VkDeviceSize dstOffset, VkDeviceSize dataSize, |
| 3764 | const void *pData) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3765 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3766 | |
| 3767 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3768 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dstOffset-00036", |
| 3769 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3770 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3771 | } |
| 3772 | |
| 3773 | if ((dataSize <= 0) || (dataSize > 65536)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3774 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00037", |
| 3775 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 |
| 3776 | "), must be greater than zero and less than or equal to 65536.", |
| 3777 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3778 | } else if (dataSize & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3779 | skip |= LogError(device, "VUID-vkCmdUpdateBuffer-dataSize-00038", |
| 3780 | "vkCmdUpdateBuffer() parameter, VkDeviceSize dataSize (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3781 | dataSize); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3782 | } |
| 3783 | return skip; |
| 3784 | } |
| 3785 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3786 | bool StatelessValidation::manual_PreCallValidateCmdFillBuffer(VkCommandBuffer commandBuffer, VkBuffer dstBuffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3787 | VkDeviceSize dstOffset, VkDeviceSize size, uint32_t data) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3788 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3789 | |
| 3790 | if (dstOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3791 | skip |= LogError(device, "VUID-vkCmdFillBuffer-dstOffset-00025", |
| 3792 | "vkCmdFillBuffer() parameter, VkDeviceSize dstOffset (0x%" PRIxLEAST64 "), is not a multiple of 4.", |
| 3793 | dstOffset); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3794 | } |
| 3795 | |
| 3796 | if (size != VK_WHOLE_SIZE) { |
| 3797 | if (size <= 0) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3798 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3799 | LogError(device, "VUID-vkCmdFillBuffer-size-00026", |
| 3800 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), must be greater than zero.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3801 | } else if (size & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3802 | skip |= LogError(device, "VUID-vkCmdFillBuffer-size-00028", |
| 3803 | "vkCmdFillBuffer() parameter, VkDeviceSize size (0x%" PRIxLEAST64 "), is not a multiple of 4.", size); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3804 | } |
| 3805 | } |
| 3806 | return skip; |
| 3807 | } |
| 3808 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3809 | bool StatelessValidation::manual_PreCallValidateCreateSwapchainKHR(VkDevice device, const VkSwapchainCreateInfoKHR *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3810 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3811 | VkSwapchainKHR *pSwapchain) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3812 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3813 | |
| 3814 | if (pCreateInfo != nullptr) { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3815 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 3816 | if (pCreateInfo->imageSharingMode == VK_SHARING_MODE_CONCURRENT) { |
| 3817 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, queueFamilyIndexCount must be greater than 1 |
| 3818 | if (pCreateInfo->queueFamilyIndexCount <= 1) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3819 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01278", |
| 3820 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 3821 | "pCreateInfo->queueFamilyIndexCount must be greater than 1."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3822 | } |
| 3823 | |
| 3824 | // If imageSharingMode is VK_SHARING_MODE_CONCURRENT, pQueueFamilyIndices must be a pointer to an array of |
| 3825 | // queueFamilyIndexCount uint32_t values |
| 3826 | if (pCreateInfo->pQueueFamilyIndices == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3827 | skip |= LogError(device, "VUID-VkSwapchainCreateInfoKHR-imageSharingMode-01277", |
| 3828 | "vkCreateSwapchainKHR(): if pCreateInfo->imageSharingMode is VK_SHARING_MODE_CONCURRENT, " |
| 3829 | "pCreateInfo->pQueueFamilyIndices must be a pointer to an array of " |
| 3830 | "pCreateInfo->queueFamilyIndexCount uint32_t values."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3831 | } |
| 3832 | } |
| 3833 | |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3834 | skip |= ValidateGreaterThanZero(pCreateInfo->imageArrayLayers, "pCreateInfo->imageArrayLayers", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3835 | "VUID-VkSwapchainCreateInfoKHR-imageArrayLayers-01275", "vkCreateSwapchainKHR"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3836 | } |
| 3837 | |
| 3838 | return skip; |
| 3839 | } |
| 3840 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3841 | bool StatelessValidation::manual_PreCallValidateQueuePresentKHR(VkQueue queue, const VkPresentInfoKHR *pPresentInfo) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3842 | bool skip = false; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3843 | |
| 3844 | if (pPresentInfo && pPresentInfo->pNext) { |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3845 | const auto *present_regions = lvl_find_in_chain<VkPresentRegionsKHR>(pPresentInfo->pNext); |
| 3846 | if (present_regions) { |
| 3847 | // TODO: This and all other pNext extension dependencies should be added to code-generation |
Tony-LunarG | 2ec96bb | 2019-11-26 13:43:02 -0700 | [diff] [blame] | 3848 | skip |= require_device_extension(IsExtEnabled(device_extensions.vk_khr_incremental_present), "vkQueuePresentKHR", |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3849 | VK_KHR_INCREMENTAL_PRESENT_EXTENSION_NAME); |
| 3850 | if (present_regions->swapchainCount != pPresentInfo->swapchainCount) { |
sfricke-samsung | a4cc4ff | 2020-08-23 22:05:49 -0700 | [diff] [blame] | 3851 | skip |= LogError(device, "VUID-VkPresentRegionsKHR-swapchainCount-01260", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3852 | "QueuePresentKHR(): pPresentInfo->swapchainCount has a value of %i but VkPresentRegionsKHR " |
| 3853 | "extension swapchainCount is %i. These values must be equal.", |
| 3854 | pPresentInfo->swapchainCount, present_regions->swapchainCount); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3855 | } |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3856 | skip |= validate_struct_pnext("QueuePresentKHR", "pCreateInfo->pNext->pNext", NULL, present_regions->pNext, 0, NULL, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 3857 | GeneratedVulkanHeaderVersion, "VUID-VkPresentInfoKHR-pNext-pNext", |
| 3858 | "VUID-VkPresentInfoKHR-sType-unique"); |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3859 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->swapchainCount", "pCreateInfo->pNext->pRegions", |
| 3860 | present_regions->swapchainCount, &present_regions->pRegions, true, false, kVUIDUndefined, |
| 3861 | kVUIDUndefined); |
John Zulauf | de972ac | 2017-10-26 12:07:05 -0600 | [diff] [blame] | 3862 | for (uint32_t i = 0; i < present_regions->swapchainCount; ++i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3863 | skip |= validate_array("QueuePresentKHR", "pCreateInfo->pNext->pRegions[].rectangleCount", |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3864 | "pCreateInfo->pNext->pRegions[].pRectangles", present_regions->pRegions[i].rectangleCount, |
Dave Houlton | 413a678 | 2018-05-22 13:01:54 -0600 | [diff] [blame] | 3865 | &present_regions->pRegions[i].pRectangles, true, false, kVUIDUndefined, kVUIDUndefined); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3866 | } |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3867 | } |
| 3868 | } |
| 3869 | |
| 3870 | return skip; |
| 3871 | } |
| 3872 | |
sfricke-samsung | 5c1b739 | 2020-12-13 22:17:15 -0800 | [diff] [blame] | 3873 | bool StatelessValidation::manual_PreCallValidateCreateDisplayModeKHR(VkPhysicalDevice physicalDevice, VkDisplayKHR display, |
| 3874 | const VkDisplayModeCreateInfoKHR *pCreateInfo, |
| 3875 | const VkAllocationCallbacks *pAllocator, |
| 3876 | VkDisplayModeKHR *pMode) const { |
| 3877 | bool skip = false; |
| 3878 | |
| 3879 | const VkDisplayModeParametersKHR display_mode_parameters = pCreateInfo->parameters; |
| 3880 | if (display_mode_parameters.visibleRegion.width == 0) { |
| 3881 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-width-01990", |
| 3882 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.width must be greater than 0."); |
| 3883 | } |
| 3884 | if (display_mode_parameters.visibleRegion.height == 0) { |
| 3885 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-height-01991", |
| 3886 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.visibleRegion.height must be greater than 0."); |
| 3887 | } |
| 3888 | if (display_mode_parameters.refreshRate == 0) { |
| 3889 | skip |= LogError(device, "VUID-VkDisplayModeParametersKHR-refreshRate-01992", |
| 3890 | "vkCreateDisplayModeKHR(): pCreateInfo->parameters.refreshRate must be greater than 0."); |
| 3891 | } |
| 3892 | |
| 3893 | return skip; |
| 3894 | } |
| 3895 | |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3896 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3897 | bool StatelessValidation::manual_PreCallValidateCreateWin32SurfaceKHR(VkInstance instance, |
| 3898 | const VkWin32SurfaceCreateInfoKHR *pCreateInfo, |
| 3899 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3900 | VkSurfaceKHR *pSurface) const { |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3901 | bool skip = false; |
| 3902 | |
| 3903 | if (pCreateInfo->hwnd == nullptr) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3904 | skip |= LogError(device, "VUID-VkWin32SurfaceCreateInfoKHR-hwnd-01308", |
| 3905 | "vkCreateWin32SurfaceKHR(): hwnd must be a valid Win32 HWND but hwnd is NULL."); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 3906 | } |
| 3907 | |
| 3908 | return skip; |
| 3909 | } |
| 3910 | #endif // VK_USE_PLATFORM_WIN32_KHR |
| 3911 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3912 | bool StatelessValidation::manual_PreCallValidateCreateDescriptorPool(VkDevice device, const VkDescriptorPoolCreateInfo *pCreateInfo, |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3913 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3914 | VkDescriptorPool *pDescriptorPool) const { |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3915 | bool skip = false; |
| 3916 | |
| 3917 | if (pCreateInfo) { |
| 3918 | if (pCreateInfo->maxSets <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3919 | skip |= LogError(device, "VUID-VkDescriptorPoolCreateInfo-maxSets-00301", |
| 3920 | "vkCreateDescriptorPool(): pCreateInfo->maxSets is not greater than 0."); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3921 | } |
| 3922 | |
| 3923 | if (pCreateInfo->pPoolSizes) { |
| 3924 | for (uint32_t i = 0; i < pCreateInfo->poolSizeCount; ++i) { |
| 3925 | if (pCreateInfo->pPoolSizes[i].descriptorCount <= 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3926 | skip |= LogError( |
| 3927 | device, "VUID-VkDescriptorPoolSize-descriptorCount-00302", |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3928 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not greater than 0.", i); |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3929 | } |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 3930 | if (pCreateInfo->pPoolSizes[i].type == VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT && |
| 3931 | (pCreateInfo->pPoolSizes[i].descriptorCount % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3932 | skip |= LogError(device, "VUID-VkDescriptorPoolSize-type-02218", |
| 3933 | "vkCreateDescriptorPool(): pCreateInfo->pPoolSizes[%" PRIu32 |
| 3934 | "].type is VK_DESCRIPTOR_TYPE_INLINE_UNIFORM_BLOCK_EXT " |
| 3935 | " and pCreateInfo->pPoolSizes[%" PRIu32 "].descriptorCount is not a multiple of 4.", |
| 3936 | i, i); |
Jeff Bolz | e54ae89 | 2018-09-08 12:16:29 -0500 | [diff] [blame] | 3937 | } |
Petr Kraus | c8655be | 2017-09-27 18:56:51 +0200 | [diff] [blame] | 3938 | } |
| 3939 | } |
| 3940 | } |
| 3941 | |
| 3942 | return skip; |
| 3943 | } |
| 3944 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3945 | bool StatelessValidation::manual_PreCallValidateCmdDispatch(VkCommandBuffer commandBuffer, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3946 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3947 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3948 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3949 | if (groupCountX > device_limits.maxComputeWorkGroupCount[0]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3950 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3951 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountX-00386", |
| 3952 | "vkCmdDispatch(): groupCountX (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3953 | groupCountX, device_limits.maxComputeWorkGroupCount[0]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3954 | } |
| 3955 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3956 | if (groupCountY > device_limits.maxComputeWorkGroupCount[1]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3957 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3958 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountY-00387", |
| 3959 | "vkCmdDispatch(): groupCountY (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 3960 | groupCountY, device_limits.maxComputeWorkGroupCount[1]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3961 | } |
| 3962 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3963 | if (groupCountZ > device_limits.maxComputeWorkGroupCount[2]) { |
Mark Lobodzinski | 487a0d1 | 2018-03-30 10:09:03 -0600 | [diff] [blame] | 3964 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3965 | LogError(commandBuffer, "VUID-vkCmdDispatch-groupCountZ-00388", |
| 3966 | "vkCmdDispatch(): groupCountZ (%" PRIu32 ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 3967 | groupCountZ, device_limits.maxComputeWorkGroupCount[2]); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3968 | } |
| 3969 | |
| 3970 | return skip; |
| 3971 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3972 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3973 | bool StatelessValidation::manual_PreCallValidateCmdDispatchIndirect(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3974 | VkDeviceSize offset) const { |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3975 | bool skip = false; |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3976 | |
| 3977 | if ((offset % 4) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3978 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchIndirect-offset-02710", |
| 3979 | "vkCmdDispatchIndirect(): offset (%" PRIu64 ") must be a multiple of 4.", offset); |
John Zulauf | a999d1b | 2018-11-29 13:38:40 -0700 | [diff] [blame] | 3980 | } |
| 3981 | return skip; |
| 3982 | } |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3983 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 3984 | bool StatelessValidation::manual_PreCallValidateCmdDispatchBaseKHR(VkCommandBuffer commandBuffer, uint32_t baseGroupX, |
| 3985 | uint32_t baseGroupY, uint32_t baseGroupZ, uint32_t groupCountX, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 3986 | uint32_t groupCountY, uint32_t groupCountZ) const { |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3987 | bool skip = false; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3988 | |
| 3989 | // Paired if {} else if {} tests used to avoid any possible uint underflow |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 3990 | uint32_t limit = device_limits.maxComputeWorkGroupCount[0]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3991 | if (baseGroupX >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3992 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00421", |
| 3993 | "vkCmdDispatch(): baseGroupX (%" PRIu32 |
| 3994 | ") equals or exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 3995 | baseGroupX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 3996 | } else if (groupCountX > (limit - baseGroupX)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 3997 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountX-00424", |
| 3998 | "vkCmdDispatchBaseKHR(): baseGroupX (%" PRIu32 ") + groupCountX (%" PRIu32 |
| 3999 | ") exceeds device limit maxComputeWorkGroupCount[0] (%" PRIu32 ").", |
| 4000 | baseGroupX, groupCountX, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4001 | } |
| 4002 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4003 | limit = device_limits.maxComputeWorkGroupCount[1]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4004 | if (baseGroupY >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4005 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupX-00422", |
| 4006 | "vkCmdDispatch(): baseGroupY (%" PRIu32 |
| 4007 | ") equals or exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 4008 | baseGroupY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4009 | } else if (groupCountY > (limit - baseGroupY)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4010 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountY-00425", |
| 4011 | "vkCmdDispatchBaseKHR(): baseGroupY (%" PRIu32 ") + groupCountY (%" PRIu32 |
| 4012 | ") exceeds device limit maxComputeWorkGroupCount[1] (%" PRIu32 ").", |
| 4013 | baseGroupY, groupCountY, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4014 | } |
| 4015 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4016 | limit = device_limits.maxComputeWorkGroupCount[2]; |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4017 | if (baseGroupZ >= limit) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4018 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-baseGroupZ-00423", |
| 4019 | "vkCmdDispatch(): baseGroupZ (%" PRIu32 |
| 4020 | ") equals or exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 4021 | baseGroupZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4022 | } else if (groupCountZ > (limit - baseGroupZ)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4023 | skip |= LogError(commandBuffer, "VUID-vkCmdDispatchBase-groupCountZ-00426", |
| 4024 | "vkCmdDispatchBaseKHR(): baseGroupZ (%" PRIu32 ") + groupCountZ (%" PRIu32 |
| 4025 | ") exceeds device limit maxComputeWorkGroupCount[2] (%" PRIu32 ").", |
| 4026 | baseGroupZ, groupCountZ, limit); |
Dave Houlton | bb7d3fe | 2018-01-11 17:09:16 -0700 | [diff] [blame] | 4027 | } |
| 4028 | |
| 4029 | return skip; |
| 4030 | } |
| 4031 | |
Jeremy Hayes | 390ff6f | 2020-02-10 13:48:57 -0700 | [diff] [blame] | 4032 | bool StatelessValidation::manual_PreCallValidateCmdPushDescriptorSetKHR(VkCommandBuffer commandBuffer, |
| 4033 | VkPipelineBindPoint pipelineBindPoint, |
| 4034 | VkPipelineLayout layout, uint32_t set, |
| 4035 | uint32_t descriptorWriteCount, |
| 4036 | const VkWriteDescriptorSet *pDescriptorWrites) const { |
| 4037 | return validate_WriteDescriptorSet("vkCmdPushDescriptorSetKHR", descriptorWriteCount, pDescriptorWrites, false); |
| 4038 | } |
| 4039 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4040 | bool StatelessValidation::manual_PreCallValidateCmdSetExclusiveScissorNV(VkCommandBuffer commandBuffer, |
| 4041 | uint32_t firstExclusiveScissor, |
| 4042 | uint32_t exclusiveScissorCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4043 | const VkRect2D *pExclusiveScissors) const { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4044 | bool skip = false; |
| 4045 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4046 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4047 | if (firstExclusiveScissor != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4048 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4049 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02035", |
| 4050 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but firstExclusiveScissor (=%" PRIu32 |
| 4051 | ") is not 0.", |
| 4052 | firstExclusiveScissor); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4053 | } |
| 4054 | if (exclusiveScissorCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4055 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4056 | LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-exclusiveScissorCount-02036", |
| 4057 | "vkCmdSetExclusiveScissorNV: The multiViewport feature is disabled, but exclusiveScissorCount (=%" PRIu32 |
| 4058 | ") is not 1.", |
| 4059 | exclusiveScissorCount); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4060 | } |
| 4061 | } else { // multiViewport enabled |
| 4062 | const uint64_t sum = static_cast<uint64_t>(firstExclusiveScissor) + static_cast<uint64_t>(exclusiveScissorCount); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4063 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4064 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-firstExclusiveScissor-02034", |
| 4065 | "vkCmdSetExclusiveScissorNV: firstExclusiveScissor + exclusiveScissorCount (=%" PRIu32 " + %" PRIu32 |
| 4066 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4067 | firstExclusiveScissor, exclusiveScissorCount, sum, device_limits.maxViewports); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4068 | } |
| 4069 | } |
| 4070 | |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4071 | if (pExclusiveScissors) { |
| 4072 | for (uint32_t scissor_i = 0; scissor_i < exclusiveScissorCount; ++scissor_i) { |
| 4073 | const auto &scissor = pExclusiveScissors[scissor_i]; // will crash on invalid ptr |
| 4074 | |
| 4075 | if (scissor.offset.x < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4076 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 4077 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", |
| 4078 | scissor_i, scissor.offset.x); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4079 | } |
| 4080 | |
| 4081 | if (scissor.offset.y < 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4082 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-x-02037", |
| 4083 | "vkCmdSetExclusiveScissorNV: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", |
| 4084 | scissor_i, scissor.offset.y); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4085 | } |
| 4086 | |
| 4087 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 4088 | if (x_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4089 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02038", |
| 4090 | "vkCmdSetExclusiveScissorNV: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4091 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4092 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4093 | } |
| 4094 | |
| 4095 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 4096 | if (y_sum > INT32_MAX) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4097 | skip |= LogError(commandBuffer, "VUID-vkCmdSetExclusiveScissorNV-offset-02039", |
| 4098 | "vkCmdSetExclusiveScissorNV: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 4099 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 4100 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
Jeff Bolz | 3e71f78 | 2018-08-29 23:15:45 -0500 | [diff] [blame] | 4101 | } |
| 4102 | } |
| 4103 | } |
| 4104 | |
| 4105 | return skip; |
| 4106 | } |
| 4107 | |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4108 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWScalingNV(VkCommandBuffer commandBuffer, uint32_t firstViewport, |
| 4109 | uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4110 | const VkViewportWScalingNV *pViewportWScalings) const { |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4111 | bool skip = false; |
Shannon McPherson | 169d0c7 | 2020-11-13 18:48:19 -0700 | [diff] [blame] | 4112 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
| 4113 | if ((sum < 1) || (sum > device_limits.maxViewports)) { |
| 4114 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWScalingNV-firstViewport-01324", |
| 4115 | "vkCmdSetViewportWScalingNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 " = %" PRIu64 |
| 4116 | ") must be between 1 and VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 "), inculsive.", |
| 4117 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Chris Mayer | 9ded5eb | 2019-09-19 16:33:26 +0200 | [diff] [blame] | 4118 | } |
| 4119 | |
| 4120 | return skip; |
| 4121 | } |
| 4122 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4123 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportShadingRatePaletteNV( |
| 4124 | VkCommandBuffer commandBuffer, uint32_t firstViewport, uint32_t viewportCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4125 | const VkShadingRatePaletteNV *pShadingRatePalettes) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4126 | bool skip = false; |
| 4127 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4128 | if (!physical_device_features.multiViewport) { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4129 | if (firstViewport != 0) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4130 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4131 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02068", |
| 4132 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but firstViewport (=%" PRIu32 |
| 4133 | ") is not 0.", |
| 4134 | firstViewport); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4135 | } |
| 4136 | if (viewportCount > 1) { |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4137 | skip |= |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4138 | LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-viewportCount-02069", |
| 4139 | "vkCmdSetViewportShadingRatePaletteNV: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 4140 | ") is not 1.", |
| 4141 | viewportCount); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4142 | } |
| 4143 | } |
| 4144 | |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4145 | const uint64_t sum = static_cast<uint64_t>(firstViewport) + static_cast<uint64_t>(viewportCount); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4146 | if (sum > device_limits.maxViewports) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4147 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportShadingRatePaletteNV-firstViewport-02067", |
| 4148 | "vkCmdSetViewportShadingRatePaletteNV: firstViewport + viewportCount (=%" PRIu32 " + %" PRIu32 |
| 4149 | " = %" PRIu64 ") is greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 4150 | firstViewport, viewportCount, sum, device_limits.maxViewports); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4151 | } |
| 4152 | |
| 4153 | return skip; |
| 4154 | } |
| 4155 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4156 | bool StatelessValidation::manual_PreCallValidateCmdSetCoarseSampleOrderNV( |
| 4157 | VkCommandBuffer commandBuffer, VkCoarseSampleOrderTypeNV sampleOrderType, uint32_t customSampleOrderCount, |
| 4158 | const VkCoarseSampleOrderCustomNV *pCustomSampleOrders) const { |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4159 | bool skip = false; |
| 4160 | |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4161 | if (sampleOrderType != VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV && customSampleOrderCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4162 | skip |= LogError(commandBuffer, "VUID-vkCmdSetCoarseSampleOrderNV-sampleOrderType-02081", |
| 4163 | "vkCmdSetCoarseSampleOrderNV: If sampleOrderType is not VK_COARSE_SAMPLE_ORDER_TYPE_CUSTOM_NV, " |
| 4164 | "customSampleOrderCount must be 0."); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4165 | } |
| 4166 | |
| 4167 | for (uint32_t order_i = 0; order_i < customSampleOrderCount; ++order_i) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4168 | skip |= ValidateCoarseSampleOrderCustomNV(&pCustomSampleOrders[order_i]); |
Jeff Bolz | 9af91c5 | 2018-09-01 21:53:57 -0500 | [diff] [blame] | 4169 | } |
| 4170 | |
| 4171 | return skip; |
| 4172 | } |
| 4173 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4174 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksNV(VkCommandBuffer commandBuffer, uint32_t taskCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4175 | uint32_t firstTask) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4176 | bool skip = false; |
| 4177 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4178 | if (taskCount > phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4179 | skip |= LogError( |
| 4180 | commandBuffer, "VUID-vkCmdDrawMeshTasksNV-taskCount-02119", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4181 | "vkCmdDrawMeshTasksNV() parameter, uint32_t taskCount (0x%" PRIxLEAST32 |
| 4182 | "), must be less than or equal to VkPhysicalDeviceMeshShaderPropertiesNV::maxDrawMeshTasksCount (0x%" PRIxLEAST32 ").", |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4183 | taskCount, phys_dev_ext_props.mesh_shader_props.maxDrawMeshTasksCount); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4184 | } |
| 4185 | |
| 4186 | return skip; |
| 4187 | } |
| 4188 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4189 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4190 | VkDeviceSize offset, uint32_t drawCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4191 | uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4192 | bool skip = false; |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4193 | static const int condition_multiples = 0b0011; |
| 4194 | if (offset & condition_multiples) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4195 | skip |= LogError( |
| 4196 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-offset-02710", |
Dave Houlton | 142c4cb | 2018-10-17 15:04:41 -0600 | [diff] [blame] | 4197 | "vkCmdDrawMeshTasksIndirectNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 "), is not a multiple of 4.", offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4198 | } |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4199 | if (drawCount > 1 && ((stride & condition_multiples) || stride < sizeof(VkDrawMeshTasksIndirectCommandNV))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4200 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02146", |
| 4201 | "vkCmdDrawMeshTasksIndirectNV() parameter, uint32_t stride (0x%" PRIxLEAST32 |
| 4202 | "), is not a multiple of 4 or smaller than sizeof (VkDrawMeshTasksIndirectCommandNV).", |
| 4203 | stride); |
Locke | e1c2288 | 2019-06-10 16:02:54 -0600 | [diff] [blame] | 4204 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4205 | if (!physical_device_features.multiDrawIndirect && ((drawCount > 1))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4206 | skip |= LogError( |
| 4207 | commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02718", |
| 4208 | "vkCmdDrawMeshTasksIndirectNV(): Device feature multiDrawIndirect disabled: count must be 0 or 1 but is %d", drawCount); |
Jeff Bolz | b574c34 | 2018-11-08 15:36:57 -0600 | [diff] [blame] | 4209 | } |
Tony-LunarG | c0c3df5 | 2020-11-20 13:47:10 -0700 | [diff] [blame] | 4210 | if (drawCount > device_limits.maxDrawIndirectCount) { |
| 4211 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectNV-drawCount-02719", |
| 4212 | "vkCmdDrawMeshTasksIndirectNV: drawCount (%u) is not less than or equal to the maximum allowed (%u).", drawCount, |
| 4213 | device_limits.maxDrawIndirectCount); |
| 4214 | } |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4215 | return skip; |
| 4216 | } |
| 4217 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4218 | bool StatelessValidation::manual_PreCallValidateCmdDrawMeshTasksIndirectCountNV(VkCommandBuffer commandBuffer, VkBuffer buffer, |
| 4219 | VkDeviceSize offset, VkBuffer countBuffer, |
| 4220 | VkDeviceSize countBufferOffset, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4221 | uint32_t maxDrawCount, uint32_t stride) const { |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4222 | bool skip = false; |
| 4223 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4224 | if (offset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4225 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-offset-02710", |
| 4226 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize offset (0x%" PRIxLEAST64 |
| 4227 | "), is not a multiple of 4.", |
| 4228 | offset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4229 | } |
| 4230 | |
| 4231 | if (countBufferOffset & 3) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4232 | skip |= LogError(commandBuffer, "VUID-vkCmdDrawMeshTasksIndirectCountNV-countBufferOffset-02716", |
| 4233 | "vkCmdDrawMeshTasksIndirectCountNV() parameter, VkDeviceSize countBufferOffset (0x%" PRIxLEAST64 |
| 4234 | "), is not a multiple of 4.", |
| 4235 | countBufferOffset); |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4236 | } |
| 4237 | |
Jeff Bolz | 45bf7d6 | 2018-09-18 15:39:58 -0500 | [diff] [blame] | 4238 | return skip; |
| 4239 | } |
| 4240 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4241 | bool StatelessValidation::manual_PreCallValidateCreateQueryPool(VkDevice device, const VkQueryPoolCreateInfo *pCreateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4242 | const VkAllocationCallbacks *pAllocator, |
| 4243 | VkQueryPool *pQueryPool) const { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4244 | bool skip = false; |
| 4245 | |
| 4246 | // Validation for parameters excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4247 | if (pCreateInfo != nullptr) { |
| 4248 | // If queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, pipelineStatistics must be a valid combination of |
| 4249 | // VkQueryPipelineStatisticFlagBits values |
| 4250 | if ((pCreateInfo->queryType == VK_QUERY_TYPE_PIPELINE_STATISTICS) && (pCreateInfo->pipelineStatistics != 0) && |
| 4251 | ((pCreateInfo->pipelineStatistics & (~AllVkQueryPipelineStatisticFlagBits)) != 0)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4252 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryType-00792", |
| 4253 | "vkCreateQueryPool(): if pCreateInfo->queryType is VK_QUERY_TYPE_PIPELINE_STATISTICS, " |
| 4254 | "pCreateInfo->pipelineStatistics must be a valid combination of VkQueryPipelineStatisticFlagBits " |
| 4255 | "values."); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4256 | } |
sfricke-samsung | 7d69d0d | 2020-04-25 10:27:27 -0700 | [diff] [blame] | 4257 | if (pCreateInfo->queryCount == 0) { |
| 4258 | skip |= LogError(device, "VUID-VkQueryPoolCreateInfo-queryCount-02763", |
| 4259 | "vkCreateQueryPool(): queryCount must be greater than zero."); |
| 4260 | } |
Mark Lobodzinski | b7a2638 | 2018-07-02 13:14:26 -0600 | [diff] [blame] | 4261 | } |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4262 | return skip; |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4263 | } |
| 4264 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4265 | bool StatelessValidation::manual_PreCallValidateEnumerateDeviceExtensionProperties(VkPhysicalDevice physicalDevice, |
| 4266 | const char *pLayerName, uint32_t *pPropertyCount, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4267 | VkExtensionProperties *pProperties) const { |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4268 | return validate_array("vkEnumerateDeviceExtensionProperties", "pPropertyCount", "pProperties", pPropertyCount, &pProperties, |
| 4269 | true, false, false, kVUIDUndefined, "VUID-vkEnumerateDeviceExtensionProperties-pProperties-parameter"); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4270 | } |
| 4271 | |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4272 | void StatelessValidation::PostCallRecordCreateRenderPass(VkDevice device, const VkRenderPassCreateInfo *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 4273 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 4274 | VkResult result) { |
| 4275 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4276 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4277 | } |
| 4278 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4279 | void StatelessValidation::PostCallRecordCreateRenderPass2KHR(VkDevice device, const VkRenderPassCreateInfo2 *pCreateInfo, |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 4280 | const VkAllocationCallbacks *pAllocator, VkRenderPass *pRenderPass, |
| 4281 | VkResult result) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4282 | // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments) |
Mark Lobodzinski | cd05c1e | 2019-01-17 15:33:46 -0700 | [diff] [blame] | 4283 | if (result != VK_SUCCESS) return; |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4284 | RecordRenderPass(*pRenderPass, pCreateInfo); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4285 | } |
| 4286 | |
Mark Lobodzinski | bf599b9 | 2018-12-31 12:15:55 -0700 | [diff] [blame] | 4287 | void StatelessValidation::PostCallRecordDestroyRenderPass(VkDevice device, VkRenderPass renderPass, |
| 4288 | const VkAllocationCallbacks *pAllocator) { |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4289 | // Track the state necessary for checking vkCreateGraphicsPipeline (subpass usage of depth and color attachments) |
Mark Lobodzinski | f27a6bc | 2019-02-04 13:00:49 -0700 | [diff] [blame] | 4290 | std::unique_lock<std::mutex> lock(renderpass_map_mutex); |
Mark Lobodzinski | af7c038 | 2018-12-18 11:55:55 -0700 | [diff] [blame] | 4291 | renderpasses_states.erase(renderPass); |
Mark Lobodzinski | d495007 | 2017-08-01 13:02:20 -0600 | [diff] [blame] | 4292 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4293 | |
Tony-LunarG | 3c287f6 | 2020-12-17 12:39:49 -0700 | [diff] [blame^] | 4294 | void StatelessValidation::PostCallRecordAllocateCommandBuffers(VkDevice device, const VkCommandBufferAllocateInfo *pAllocateInfo, |
| 4295 | VkCommandBuffer *pCommandBuffers, VkResult result) { |
| 4296 | if ((result == VK_SUCCESS) && pAllocateInfo && (pAllocateInfo->level == VK_COMMAND_BUFFER_LEVEL_SECONDARY)) { |
| 4297 | auto lock = cb_write_lock(); |
| 4298 | for (uint32_t cb_index = 0; cb_index < pAllocateInfo->commandBufferCount; cb_index++) { |
| 4299 | secondary_cb_map.insert({ pCommandBuffers[cb_index], pAllocateInfo->commandPool }); |
| 4300 | } |
| 4301 | } |
| 4302 | } |
| 4303 | |
| 4304 | void StatelessValidation::PostCallRecordFreeCommandBuffers(VkDevice device, VkCommandPool commandPool, uint32_t commandBufferCount, |
| 4305 | const VkCommandBuffer *pCommandBuffers) { |
| 4306 | auto lock = cb_write_lock(); |
| 4307 | for (uint32_t cb_index = 0; cb_index < commandBufferCount; cb_index++) { |
| 4308 | secondary_cb_map.erase(pCommandBuffers[cb_index]); |
| 4309 | } |
| 4310 | } |
| 4311 | |
| 4312 | void StatelessValidation::PostCallRecordDestroyCommandPool(VkDevice device, VkCommandPool commandPool, |
| 4313 | const VkAllocationCallbacks *pAllocator) { |
| 4314 | auto lock = cb_write_lock(); |
| 4315 | for (auto item = secondary_cb_map.begin(); item != secondary_cb_map.end();) { |
| 4316 | if (item->second == commandPool) { |
| 4317 | item = secondary_cb_map.erase(item); |
| 4318 | } |
| 4319 | else { |
| 4320 | ++item; |
| 4321 | } |
| 4322 | } |
| 4323 | } |
| 4324 | |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4325 | bool StatelessValidation::manual_PreCallValidateAllocateMemory(VkDevice device, const VkMemoryAllocateInfo *pAllocateInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4326 | const VkAllocationCallbacks *pAllocator, |
| 4327 | VkDeviceMemory *pMemory) const { |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4328 | bool skip = false; |
| 4329 | |
| 4330 | if (pAllocateInfo) { |
| 4331 | auto chained_prio_struct = lvl_find_in_chain<VkMemoryPriorityAllocateInfoEXT>(pAllocateInfo->pNext); |
| 4332 | if (chained_prio_struct && (chained_prio_struct->priority < 0.0f || chained_prio_struct->priority > 1.0f)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4333 | skip |= LogError(device, "VUID-VkMemoryPriorityAllocateInfoEXT-priority-02602", |
| 4334 | "priority (=%f) must be between `0` and `1`, inclusive.", chained_prio_struct->priority); |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4335 | } |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4336 | |
| 4337 | VkMemoryAllocateFlags flags = 0; |
| 4338 | auto flags_info = lvl_find_in_chain<VkMemoryAllocateFlagsInfo>(pAllocateInfo->pNext); |
| 4339 | if (flags_info) { |
| 4340 | flags = flags_info->flags; |
| 4341 | } |
| 4342 | |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4343 | auto opaque_alloc_info = lvl_find_in_chain<VkMemoryOpaqueCaptureAddressAllocateInfo>(pAllocateInfo->pNext); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4344 | if (opaque_alloc_info && opaque_alloc_info->opaqueCaptureAddress != 0) { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4345 | if (!(flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4346 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03329", |
| 4347 | "If opaqueCaptureAddress is non-zero, VkMemoryAllocateFlagsInfo::flags must include " |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4348 | "VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4349 | } |
| 4350 | |
| 4351 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 4352 | auto import_memory_win32_handle = lvl_find_in_chain<VkImportMemoryWin32HandleInfoKHR>(pAllocateInfo->pNext); |
| 4353 | #endif |
| 4354 | auto import_memory_fd = lvl_find_in_chain<VkImportMemoryFdInfoKHR>(pAllocateInfo->pNext); |
| 4355 | auto import_memory_host_pointer = lvl_find_in_chain<VkImportMemoryHostPointerInfoEXT>(pAllocateInfo->pNext); |
| 4356 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 4357 | auto import_memory_ahb = lvl_find_in_chain<VkImportAndroidHardwareBufferInfoANDROID>(pAllocateInfo->pNext); |
| 4358 | #endif |
| 4359 | |
| 4360 | if (import_memory_host_pointer) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4361 | skip |= LogError( |
| 4362 | device, "VUID-VkMemoryAllocateInfo-pNext-03332", |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4363 | "If the pNext chain includes a VkImportMemoryHostPointerInfoEXT structure, opaqueCaptureAddress must be zero."); |
| 4364 | } |
| 4365 | if ( |
| 4366 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 4367 | (import_memory_win32_handle && import_memory_win32_handle->handleType) || |
| 4368 | #endif |
| 4369 | (import_memory_fd && import_memory_fd->handleType) || |
| 4370 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
| 4371 | (import_memory_ahb && import_memory_ahb->buffer) || |
| 4372 | #endif |
| 4373 | (import_memory_host_pointer && import_memory_host_pointer->handleType)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4374 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-opaqueCaptureAddress-03333", |
| 4375 | "If the parameters define an import operation, opaqueCaptureAddress must be zero."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4376 | } |
| 4377 | } |
| 4378 | |
| 4379 | if (flags) { |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 4380 | VkBool32 capture_replay = false; |
| 4381 | VkBool32 buffer_device_address = false; |
| 4382 | const auto *vulkan_12_features = lvl_find_in_chain<VkPhysicalDeviceVulkan12Features>(device_createinfo_pnext); |
| 4383 | if (vulkan_12_features) { |
| 4384 | capture_replay = vulkan_12_features->bufferDeviceAddressCaptureReplay; |
| 4385 | buffer_device_address = vulkan_12_features->bufferDeviceAddress; |
| 4386 | } else { |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4387 | const auto *bda_features = lvl_find_in_chain<VkPhysicalDeviceBufferDeviceAddressFeatures>(device_createinfo_pnext); |
Tony-LunarG | a74d3fe | 2019-11-22 15:43:20 -0700 | [diff] [blame] | 4388 | if (bda_features) { |
| 4389 | capture_replay = bda_features->bufferDeviceAddressCaptureReplay; |
| 4390 | buffer_device_address = bda_features->bufferDeviceAddress; |
| 4391 | } |
| 4392 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4393 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT) && !capture_replay) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4394 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03330", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4395 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT is set, " |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4396 | "bufferDeviceAddressCaptureReplay must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4397 | } |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4398 | if ((flags & VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT) && !buffer_device_address) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4399 | skip |= LogError(device, "VUID-VkMemoryAllocateInfo-flags-03331", |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4400 | "If VK_MEMORY_ALLOCATE_DEVICE_ADDRESS_BIT is set, bufferDeviceAddress must be enabled."); |
Jeff Bolz | 4563f2a | 2019-12-10 13:30:30 -0600 | [diff] [blame] | 4401 | } |
| 4402 | } |
Jeff Bolz | 7e7e6e0 | 2019-01-11 22:53:41 -0600 | [diff] [blame] | 4403 | } |
| 4404 | return skip; |
| 4405 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4406 | |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4407 | bool StatelessValidation::ValidateGeometryTrianglesNV(const VkGeometryTrianglesNV &triangles, |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4408 | VkAccelerationStructureNV object_handle, const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4409 | bool skip = false; |
| 4410 | |
| 4411 | if (triangles.vertexFormat != VK_FORMAT_R32G32B32_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16B16_SFLOAT && |
| 4412 | triangles.vertexFormat != VK_FORMAT_R16G16B16_SNORM && triangles.vertexFormat != VK_FORMAT_R32G32_SFLOAT && |
| 4413 | triangles.vertexFormat != VK_FORMAT_R16G16_SFLOAT && triangles.vertexFormat != VK_FORMAT_R16G16_SNORM) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4414 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexFormat-02430", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4415 | } else { |
| 4416 | uint32_t vertex_component_size = 0; |
| 4417 | if (triangles.vertexFormat == VK_FORMAT_R32G32B32_SFLOAT || triangles.vertexFormat == VK_FORMAT_R32G32_SFLOAT) { |
| 4418 | vertex_component_size = 4; |
| 4419 | } else if (triangles.vertexFormat == VK_FORMAT_R16G16B16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16B16_SNORM || |
| 4420 | triangles.vertexFormat == VK_FORMAT_R16G16_SFLOAT || triangles.vertexFormat == VK_FORMAT_R16G16_SNORM) { |
| 4421 | vertex_component_size = 2; |
| 4422 | } |
| 4423 | if (vertex_component_size > 0 && SafeModulo(triangles.vertexOffset, vertex_component_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4424 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-vertexOffset-02429", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4425 | } |
| 4426 | } |
| 4427 | |
| 4428 | if (triangles.indexType != VK_INDEX_TYPE_UINT32 && triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 4429 | triangles.indexType != VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4430 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexType-02433", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4431 | } else { |
| 4432 | uint32_t index_element_size = 0; |
| 4433 | if (triangles.indexType == VK_INDEX_TYPE_UINT32) { |
| 4434 | index_element_size = 4; |
| 4435 | } else if (triangles.indexType == VK_INDEX_TYPE_UINT16) { |
| 4436 | index_element_size = 2; |
| 4437 | } |
| 4438 | if (index_element_size > 0 && SafeModulo(triangles.indexOffset, index_element_size) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4439 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexOffset-02432", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4440 | } |
| 4441 | } |
| 4442 | if (triangles.indexType == VK_INDEX_TYPE_NONE_NV) { |
| 4443 | if (triangles.indexCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4444 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexCount-02436", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4445 | } |
| 4446 | if (triangles.indexData != VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4447 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-indexData-02434", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4448 | } |
| 4449 | } |
| 4450 | |
| 4451 | if (SafeModulo(triangles.transformOffset, 16) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4452 | skip |= LogError(object_handle, "VUID-VkGeometryTrianglesNV-transformOffset-02438", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4453 | } |
| 4454 | |
| 4455 | return skip; |
| 4456 | } |
| 4457 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4458 | bool StatelessValidation::ValidateGeometryAABBNV(const VkGeometryAABBNV &aabbs, VkAccelerationStructureNV object_handle, |
| 4459 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4460 | bool skip = false; |
| 4461 | |
| 4462 | if (SafeModulo(aabbs.offset, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4463 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-offset-02440", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4464 | } |
| 4465 | if (SafeModulo(aabbs.stride, 8) != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4466 | skip |= LogError(object_handle, "VUID-VkGeometryAABBNV-stride-02441", "%s", func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4467 | } |
| 4468 | |
| 4469 | return skip; |
| 4470 | } |
| 4471 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4472 | bool StatelessValidation::ValidateGeometryNV(const VkGeometryNV &geometry, VkAccelerationStructureNV object_handle, |
| 4473 | const char *func_name) const { |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4474 | bool skip = false; |
| 4475 | if (geometry.geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4476 | skip = ValidateGeometryTrianglesNV(geometry.geometry.triangles, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4477 | } else if (geometry.geometryType == VK_GEOMETRY_TYPE_AABBS_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4478 | skip = ValidateGeometryAABBNV(geometry.geometry.aabbs, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4479 | } |
| 4480 | return skip; |
| 4481 | } |
| 4482 | |
| 4483 | bool StatelessValidation::ValidateAccelerationStructureInfoNV(const VkAccelerationStructureInfoNV &info, |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4484 | VkAccelerationStructureNV object_handle, const char *func_name, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 4485 | bool is_cmd) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4486 | bool skip = false; |
| 4487 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV && info.geometryCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4488 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02425", |
| 4489 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_NV then " |
| 4490 | "geometryCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4491 | } |
| 4492 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.instanceCount != 0) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4493 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-type-02426", |
| 4494 | "VkAccelerationStructureInfoNV: If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV then " |
| 4495 | "instanceCount must be 0."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4496 | } |
| 4497 | if (info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV && |
| 4498 | info.flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4499 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-flags-02592", |
| 4500 | "VkAccelerationStructureInfoNV: If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_NV" |
| 4501 | "bit set, then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_NV bit set."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4502 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4503 | if (info.geometryCount > phys_dev_ext_props.ray_tracing_propsNV.maxGeometryCount) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4504 | skip |= LogError(object_handle, |
Mark Lobodzinski | 17dc460 | 2020-05-29 07:48:40 -0600 | [diff] [blame] | 4505 | is_cmd ? "VUID-vkCmdBuildAccelerationStructureNV-geometryCount-02241" |
| 4506 | : "VUID-VkAccelerationStructureInfoNV-geometryCount-02422", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4507 | "VkAccelerationStructureInfoNV: geometryCount must be less than or equal to " |
| 4508 | "VkPhysicalDeviceRayTracingPropertiesNV::maxGeometryCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4509 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4510 | if (info.instanceCount > phys_dev_ext_props.ray_tracing_propsNV.maxInstanceCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4511 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-instanceCount-02423", |
| 4512 | "VkAccelerationStructureInfoNV: instanceCount must be less than or equal to " |
| 4513 | "VkPhysicalDeviceRayTracingPropertiesNV::maxInstanceCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4514 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4515 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 0) { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4516 | uint64_t total_triangle_count = 0; |
| 4517 | for (uint32_t i = 0; i < info.geometryCount; i++) { |
| 4518 | const VkGeometryNV &geometry = info.pGeometries[i]; |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4519 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4520 | skip |= ValidateGeometryNV(geometry, object_handle, func_name); |
Jason Macnak | 192fa0e | 2019-07-26 15:07:16 -0700 | [diff] [blame] | 4521 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4522 | if (geometry.geometryType != VK_GEOMETRY_TYPE_TRIANGLES_NV) { |
| 4523 | continue; |
| 4524 | } |
| 4525 | total_triangle_count += geometry.geometry.triangles.indexCount / 3; |
| 4526 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4527 | if (total_triangle_count > phys_dev_ext_props.ray_tracing_propsNV.maxTriangleCount) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4528 | skip |= LogError(object_handle, "VUID-VkAccelerationStructureInfoNV-maxTriangleCount-02424", |
| 4529 | "VkAccelerationStructureInfoNV: The total number of triangles in all geometries must be less than " |
| 4530 | "or equal to VkPhysicalDeviceRayTracingPropertiesNV::maxTriangleCount."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4531 | } |
| 4532 | } |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4533 | if (info.type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_NV && info.geometryCount > 1) { |
| 4534 | const VkGeometryTypeNV first_geometry_type = info.pGeometries[0].geometryType; |
| 4535 | for (uint32_t i = 1; i < info.geometryCount; i++) { |
| 4536 | const VkGeometryNV &geometry = info.pGeometries[i]; |
| 4537 | if (geometry.geometryType != first_geometry_type) { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4538 | skip |= LogError(device, "VUID-VkAccelerationStructureInfoNV-type-02786", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4539 | "VkAccelerationStructureInfoNV: info.pGeometries[%d].geometryType does not match " |
| 4540 | "info.pGeometries[0].geometryType.", |
| 4541 | i); |
Jason Macnak | 21ba97e | 2019-08-09 12:57:44 -0700 | [diff] [blame] | 4542 | } |
| 4543 | } |
| 4544 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4545 | for (uint32_t geometry_index = 0; geometry_index < info.geometryCount; ++geometry_index) { |
| 4546 | if (!(info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_NV || |
| 4547 | info.pGeometries[geometry_index].geometryType == VK_GEOMETRY_TYPE_AABBS_NV)) { |
| 4548 | skip |= LogError(device, "VUID-VkGeometryNV-geometryType-03503", |
| 4549 | "VkGeometryNV: geometryType must be VK_GEOMETRY_TYPE_TRIANGLES_NV" |
| 4550 | "or VK_GEOMETRY_TYPE_AABBS_NV."); |
| 4551 | } |
| 4552 | } |
| 4553 | skip |= |
| 4554 | validate_flags(func_name, "info.flags", "VkBuildAccelerationStructureFlagBitsNV", AllVkBuildAccelerationStructureFlagBitsNV, |
Shannon McPherson | 93970b1 | 2020-06-12 14:34:35 -0600 | [diff] [blame] | 4555 | info.flags, kOptionalFlags, "VUID-VkAccelerationStructureInfoNV-flags-parameter"); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4556 | return skip; |
| 4557 | } |
| 4558 | |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4559 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureNV( |
| 4560 | VkDevice device, const VkAccelerationStructureCreateInfoNV *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4561 | VkAccelerationStructureNV *pAccelerationStructure) const { |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4562 | bool skip = false; |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4563 | if (pCreateInfo) { |
| 4564 | if ((pCreateInfo->compactedSize != 0) && |
| 4565 | ((pCreateInfo->info.geometryCount != 0) || (pCreateInfo->info.instanceCount != 0))) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4566 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoNV-compactedSize-02421", |
| 4567 | "vkCreateAccelerationStructureNV(): pCreateInfo->compactedSize nonzero (%" PRIu64 |
| 4568 | ") with info.geometryCount (%" PRIu32 ") or info.instanceCount (%" PRIu32 ") nonzero.", |
| 4569 | pCreateInfo->compactedSize, pCreateInfo->info.geometryCount, pCreateInfo->info.instanceCount); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4570 | } |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4571 | |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4572 | skip |= ValidateAccelerationStructureInfoNV(pCreateInfo->info, VkAccelerationStructureNV(0), |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4573 | "vkCreateAccelerationStructureNV()", false); |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4574 | } |
Ricardo Garcia | a493597 | 2019-02-21 17:43:18 +0100 | [diff] [blame] | 4575 | return skip; |
| 4576 | } |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4577 | |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4578 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructureNV(VkCommandBuffer commandBuffer, |
| 4579 | const VkAccelerationStructureInfoNV *pInfo, |
| 4580 | VkBuffer instanceData, VkDeviceSize instanceOffset, |
| 4581 | VkBool32 update, VkAccelerationStructureNV dst, |
| 4582 | VkAccelerationStructureNV src, VkBuffer scratch, |
| 4583 | VkDeviceSize scratchOffset) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4584 | bool skip = false; |
| 4585 | |
| 4586 | if (pInfo != nullptr) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4587 | skip |= ValidateAccelerationStructureInfoNV(*pInfo, dst, "vkCmdBuildAccelerationStructureNV()", true); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4588 | } |
| 4589 | |
| 4590 | return skip; |
| 4591 | } |
| 4592 | |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4593 | bool StatelessValidation::manual_PreCallValidateCreateAccelerationStructureKHR( |
| 4594 | VkDevice device, const VkAccelerationStructureCreateInfoKHR *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 4595 | VkAccelerationStructureKHR *pAccelerationStructure) const { |
| 4596 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4597 | const auto *acceleration_structure_features = |
| 4598 | lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
| 4599 | if (!acceleration_structure_features || |
| 4600 | (acceleration_structure_features && acceleration_structure_features->accelerationStructure == VK_FALSE)) { |
| 4601 | skip |= LogError(device, "VUID-vkCreateAccelerationStructureKHR-accelerationStructure-03611", |
| 4602 | "vkCreateAccelerationStructureKHR(): The accelerationStructure feature must be enabled"); |
| 4603 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4604 | if (pCreateInfo) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4605 | if (pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR && |
| 4606 | (!acceleration_structure_features || |
| 4607 | (acceleration_structure_features && acceleration_structure_features->accelerationStructureCaptureReplay == VK_FALSE))) { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4608 | skip |= |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4609 | LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-createFlags-03613", |
| 4610 | "vkCreateAccelerationStructureKHR(): If createFlags includes " |
| 4611 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR, " |
| 4612 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureCaptureReplay must be VK_TRUE"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4613 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4614 | if (pCreateInfo->deviceAddress && |
| 4615 | !(pCreateInfo->createFlags & VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR)) { |
| 4616 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-deviceAddress-03612", |
| 4617 | "vkCreateAccelerationStructureKHR(): If deviceAddress is not zero, createFlags must include " |
| 4618 | "VK_ACCELERATION_STRUCTURE_CREATE_DEVICE_ADDRESS_CAPTURE_REPLAY_BIT_KHR"); |
| 4619 | } |
| 4620 | if (SafeModulo(pCreateInfo->offset, 256) != 0) { |
| 4621 | skip |= LogError(device, "VUID-VkAccelerationStructureCreateInfoKHR-offset-03734", |
| 4622 | "vkCreateAccelerationStructureKHR(): offset must be a multiple of 256 bytes", pCreateInfo->offset); |
| 4623 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4624 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4625 | return skip; |
| 4626 | } |
| 4627 | |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4628 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureHandleNV(VkDevice device, |
| 4629 | VkAccelerationStructureNV accelerationStructure, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4630 | size_t dataSize, void *pData) const { |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4631 | bool skip = false; |
| 4632 | if (dataSize < 8) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4633 | skip = LogError(accelerationStructure, "VUID-vkGetAccelerationStructureHandleNV-dataSize-02240", |
| 4634 | "vkGetAccelerationStructureHandleNV(): dataSize must be greater than or equal to 8."); |
Jason Macnak | 5c95495 | 2019-07-09 15:46:12 -0700 | [diff] [blame] | 4635 | } |
| 4636 | return skip; |
| 4637 | } |
| 4638 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4639 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesNV( |
| 4640 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureNV *pAccelerationStructures, |
| 4641 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 4642 | bool skip = false; |
| 4643 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 4644 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 4645 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesNV-queryType-03432", |
| 4646 | "vkCmdWriteAccelerationStructuresPropertiesNV: queryType must be " |
| 4647 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 4648 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 4649 | } |
| 4650 | return skip; |
| 4651 | } |
| 4652 | |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4653 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesNV(VkDevice device, VkPipelineCache pipelineCache, |
| 4654 | uint32_t createInfoCount, |
| 4655 | const VkRayTracingPipelineCreateInfoNV *pCreateInfos, |
| 4656 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4657 | VkPipeline *pPipelines) const { |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4658 | bool skip = false; |
| 4659 | |
| 4660 | for (uint32_t i = 0; i < createInfoCount; i++) { |
| 4661 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 4662 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4663 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02969", |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 4664 | "vkCreateRayTracingPipelinesNV(): in pCreateInfo[%" PRIu32 |
| 4665 | "], VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
| 4666 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoNV::stageCount(=%" PRIu32 ").", |
| 4667 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4668 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4669 | |
| 4670 | const auto *pipeline_cache_contol_features = |
| 4671 | lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
| 4672 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 4673 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 4674 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 4675 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-pipelineCreationCacheControl-02905", |
| 4676 | "vkCreateRayTracingPipelinesNV(): If the pipelineCreationCacheControl feature is not enabled," |
| 4677 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 4678 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 4679 | } |
| 4680 | } |
| 4681 | |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4682 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
| 4683 | skip |= |
| 4684 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02904", |
| 4685 | "vkCreateRayTracingPipelinesNV(): flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
| 4686 | } |
| 4687 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV) && |
| 4688 | (pCreateInfos[i].flags & VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT)) { |
| 4689 | skip |= |
| 4690 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-02957", |
| 4691 | "vkCreateRayTracingPipelinesNV(): flags must not include both VK_PIPELINE_CREATE_DEFER_COMPILE_BIT_NV and" |
| 4692 | "VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT at the same time."); |
| 4693 | } |
| 4694 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 4695 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4696 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 4697 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03423", |
| 4698 | "vkCreateRayTracingPipelinesNV parameter, pCreateInfos->basePipelineHandle, must be " |
| 4699 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 4700 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 4701 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4702 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4703 | skip |= |
| 4704 | LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03415", |
| 4705 | "vkCreateRayTracingPipelinesNV: If the flags member of any element of pCreateInfos contains the" |
| 4706 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element" |
| 4707 | "is not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to " |
| 4708 | "that element."); |
| 4709 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4710 | } |
| 4711 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 4712 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4713 | skip |= |
| 4714 | LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03422", |
| 4715 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4716 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex must be a valid index into the calling" |
| 4717 | "commands pCreateInfos parameter."); |
| 4718 | } |
| 4719 | } else { |
| 4720 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4721 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03424", |
| 4722 | "vkCreateRayTracingPipelinesNV if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
| 4723 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 4724 | } |
| 4725 | } |
| 4726 | } |
| 4727 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
| 4728 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03456", |
| 4729 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_LIBRARY_BIT_KHR."); |
| 4730 | } |
| 4731 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) { |
| 4732 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03458", |
| 4733 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4734 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR."); |
| 4735 | } |
| 4736 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) { |
| 4737 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03459", |
| 4738 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4739 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR."); |
| 4740 | } |
| 4741 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR) { |
| 4742 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03460", |
| 4743 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4744 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_MISS_SHADERS_BIT_KHR."); |
| 4745 | } |
| 4746 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR) { |
| 4747 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03461", |
| 4748 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4749 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_INTERSECTION_SHADERS_BIT_KHR."); |
| 4750 | } |
| 4751 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 4752 | skip |= LogError( |
| 4753 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03462", |
| 4754 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 4755 | } |
| 4756 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 4757 | skip |= LogError( |
| 4758 | device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03463", |
| 4759 | "vkCreateRayTracingPipelinesNV: flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR ."); |
| 4760 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4761 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR) { |
| 4762 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoNV-flags-03588", |
| 4763 | "vkCreateRayTracingPipelinesNV: flags must not include " |
| 4764 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 4765 | } |
| 4766 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 4767 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesNV-flags-03816", |
| 4768 | "vkCreateRayTracingPipelinesNV: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
| 4769 | } |
Peter Chen | 8536639 | 2019-05-14 15:20:11 -0400 | [diff] [blame] | 4770 | } |
| 4771 | |
| 4772 | return skip; |
| 4773 | } |
| 4774 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4775 | bool StatelessValidation::manual_PreCallValidateCreateRayTracingPipelinesKHR( |
| 4776 | VkDevice device, VkDeferredOperationKHR deferredOperation, VkPipelineCache pipelineCache, uint32_t createInfoCount, |
| 4777 | const VkRayTracingPipelineCreateInfoKHR *pCreateInfos, const VkAllocationCallbacks *pAllocator, VkPipeline *pPipelines) const { |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4778 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4779 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
| 4780 | if (!raytracing_features || raytracing_features->rayTracingPipeline == VK_FALSE) { |
| 4781 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-rayTracingPipeline-03586", |
| 4782 | "vkCreateRayTracingPipelinesKHR: The rayTracingPipeline feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 4783 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4784 | for (uint32_t i = 0; i < createInfoCount; i++) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4785 | if (!raytracing_features || (raytracing_features && raytracing_features->rayTraversalPrimitiveCulling == VK_FALSE)) { |
| 4786 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR) { |
| 4787 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03596", |
| 4788 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 4789 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_AABBS_BIT_KHR."); |
| 4790 | } |
| 4791 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR) { |
| 4792 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTraversalPrimitiveCulling-03597", |
| 4793 | "vkCreateRayTracingPipelinesKHR: If the rayTraversalPrimitiveCulling feature is not enabled, " |
| 4794 | "flags must not include VK_PIPELINE_CREATE_RAY_TRACING_SKIP_TRIANGLES_BIT_KHR."); |
| 4795 | } |
| 4796 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4797 | auto feedback_struct = lvl_find_in_chain<VkPipelineCreationFeedbackCreateInfoEXT>(pCreateInfos[i].pNext); |
| 4798 | if ((feedback_struct != nullptr) && (feedback_struct->pipelineStageCreationFeedbackCount != pCreateInfos[i].stageCount)) { |
| 4799 | skip |= LogError(device, "VUID-VkPipelineCreationFeedbackCreateInfoEXT-pipelineStageCreationFeedbackCount-02670", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4800 | "vkCreateRayTracingPipelinesKHR: in pCreateInfo[%" PRIu32 |
| 4801 | "], When chained to VkRayTracingPipelineCreateInfoKHR, " |
| 4802 | "VkPipelineCreationFeedbackEXT::pipelineStageCreationFeedbackCount" |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4803 | "(=%" PRIu32 ") must equal VkRayTracingPipelineCreateInfoKHR::stageCount(=%" PRIu32 ").", |
| 4804 | i, feedback_struct->pipelineStageCreationFeedbackCount, pCreateInfos[i].stageCount); |
| 4805 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4806 | const auto *pipeline_cache_contol_features = |
| 4807 | lvl_find_in_chain<VkPhysicalDevicePipelineCreationCacheControlFeaturesEXT>(device_createinfo_pnext); |
| 4808 | if (!pipeline_cache_contol_features || pipeline_cache_contol_features->pipelineCreationCacheControl == VK_FALSE) { |
| 4809 | if (pCreateInfos[i].flags & (VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT | |
| 4810 | VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT)) { |
| 4811 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pipelineCreationCacheControl-02905", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4812 | "vkCreateRayTracingPipelinesKHR: If the pipelineCreationCacheControl feature is not enabled," |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 4813 | "flags must not include VK_PIPELINE_CREATE_FAIL_ON_PIPELINE_COMPILE_REQUIRED_BIT_EXT or" |
| 4814 | "VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
| 4815 | } |
| 4816 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4817 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4818 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-02904", |
| 4819 | "vkCreateRayTracingPipelinesKHR: flags must not include VK_PIPELINE_CREATE_INDIRECT_BINDABLE_BIT_NV."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4820 | } |
| 4821 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_LIBRARY_BIT_KHR) { |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4822 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4823 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03465", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4824 | "vkCreateRayTracingPipelinesKHR: If flags includes VK_PIPELINE_CREATE_LIBRARY_BIT_KHR, " |
| 4825 | "pLibraryInterface must not be NULL."); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4826 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4827 | } |
| 4828 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DISPATCH_BASE) { |
| 4829 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03816", |
| 4830 | "vkCreateRayTracingPipelinesKHR: flags must not contain the VK_PIPELINE_CREATE_DISPATCH_BASE flag."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4831 | } |
| 4832 | for (uint32_t group_index = 0; group_index < pCreateInfos[i].groupCount; ++group_index) { |
| 4833 | if ((pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR) || |
| 4834 | (pCreateInfos[i].pGroups[group_index].type == VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR)) { |
| 4835 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR) && |
| 4836 | (pCreateInfos[i].pGroups[group_index].anyHitShader == VK_SHADER_UNUSED_KHR)) { |
| 4837 | skip |= LogError( |
| 4838 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03470", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4839 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 4840 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_ANY_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4841 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 4842 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the anyHitShader of that element " |
| 4843 | "must not be VK_SHADER_UNUSED_KHR"); |
| 4844 | } |
| 4845 | if ((pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR) && |
| 4846 | (pCreateInfos[i].pGroups[group_index].closestHitShader == VK_SHADER_UNUSED_KHR)) { |
| 4847 | skip |= LogError( |
| 4848 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03471", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4849 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 4850 | "VK_PIPELINE_CREATE_RAY_TRACING_NO_NULL_CLOSEST_HIT_SHADERS_BIT_KHR," |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4851 | "for any element of pGroups with a type of VK_RAY_TRACING_SHADER_GROUP_TYPE_TRIANGLES_HIT_GROUP_KHR" |
| 4852 | "or VK_RAY_TRACING_SHADER_GROUP_TYPE_PROCEDURAL_HIT_GROUP_KHR, the closestHitShader of that " |
| 4853 | "element must not be VK_SHADER_UNUSED_KHR"); |
| 4854 | } |
| 4855 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4856 | if (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_TRUE && |
| 4857 | pCreateInfos[i].pGroups[group_index].pShaderGroupCaptureReplayHandle) { |
| 4858 | if (!(pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR)) { |
| 4859 | skip |= LogError( |
| 4860 | device, "VUID-VkRayTracingPipelineCreateInfoKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03599", |
| 4861 | "vkCreateRayTracingPipelinesKHR: If " |
| 4862 | "VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineShaderGroupHandleCaptureReplay is " |
| 4863 | "VK_TRUE and the pShaderGroupCaptureReplayHandle member of any element of pGroups is not NULL, flags must " |
| 4864 | "include VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR."); |
| 4865 | } |
| 4866 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4867 | } |
| 4868 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_DERIVATIVE_BIT) { |
| 4869 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4870 | if (pCreateInfos[i].basePipelineHandle != VK_NULL_HANDLE) { |
| 4871 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03423", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4872 | "vkCreateRayTracingPipelinesKHR: parameter, pCreateInfos->basePipelineHandle, must be " |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4873 | "VK_NULL_HANDLE if pCreateInfos->flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT flag " |
| 4874 | "and pCreateInfos->basePipelineIndex is not -1."); |
| 4875 | } |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 4876 | if (pCreateInfos[i].basePipelineIndex > static_cast<int32_t>(i)) { |
sourav parmar | a24fb7b | 2020-05-26 10:50:04 -0700 | [diff] [blame] | 4877 | skip |= |
| 4878 | LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-flags-03415", |
| 4879 | "vkCreateRayTracingPipelinesKHR: If the flags member of any element of pCreateInfos contains the" |
| 4880 | "VK_PIPELINE_CREATE_DERIVATIVE_BIT flag, and the basePipelineIndex member of that same element is" |
| 4881 | "not -1, basePipelineIndex must be less than the index into pCreateInfos that corresponds to that " |
| 4882 | "element."); |
| 4883 | } |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4884 | } |
| 4885 | if (pCreateInfos[i].basePipelineHandle == VK_NULL_HANDLE) { |
David Neto | d9d7b76 | 2020-07-27 15:37:58 -0400 | [diff] [blame] | 4886 | if (static_cast<uint32_t>(pCreateInfos[i].basePipelineIndex) >= createInfoCount) { |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4887 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03422", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4888 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4889 | "basePipelineHandle is VK_NULL_HANDLE, basePipelineIndex (%d) must be a valid into the calling" |
| 4890 | "commands pCreateInfos parameter %d.", |
| 4891 | pCreateInfos[i].basePipelineIndex, createInfoCount); |
| 4892 | } |
| 4893 | } else { |
| 4894 | if (pCreateInfos[i].basePipelineIndex != -1) { |
| 4895 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03424", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4896 | "vkCreateRayTracingPipelinesKHR: if flags contains the VK_PIPELINE_CREATE_DERIVATIVE_BIT and" |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4897 | "basePipelineHandle is not VK_NULL_HANDLE, basePipelineIndex must be -1."); |
| 4898 | } |
| 4899 | } |
| 4900 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4901 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR && |
| 4902 | (raytracing_features && raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE)) { |
| 4903 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-flags-03598", |
| 4904 | "vkCreateRayTracingPipelinesKHR: If flags includes " |
| 4905 | "VK_PIPELINE_CREATE_RAY_TRACING_SHADER_GROUP_HANDLE_CAPTURE_REPLAY_BIT_KHR, " |
| 4906 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4907 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4908 | bool library_enabled = IsExtEnabled(device_extensions.vk_khr_pipeline_library); |
| 4909 | if (!library_enabled && (pCreateInfos[i].pLibraryInfo || pCreateInfos[i].pLibraryInterface)) { |
| 4910 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03595", |
| 4911 | "vkCreateRayTracingPipelinesKHR: If the VK_KHR_pipeline_library extension is not enabled, " |
| 4912 | "pLibraryInfo and pLibraryInterface must be NULL."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4913 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 4914 | if (pCreateInfos[i].pLibraryInfo) { |
| 4915 | if (pCreateInfos[i].pLibraryInfo->libraryCount == 0) { |
| 4916 | if (pCreateInfos[i].stageCount == 0) { |
| 4917 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03600", |
| 4918 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 4919 | "stageCount must not be 0."); |
| 4920 | } |
| 4921 | if (pCreateInfos[i].groupCount == 0) { |
| 4922 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03601", |
| 4923 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount is 0, " |
| 4924 | "groupCount must not be 0."); |
| 4925 | } |
| 4926 | } else { |
| 4927 | if (pCreateInfos[i].pLibraryInterface == NULL) { |
| 4928 | skip |= LogError(device, "VUID-VkRayTracingPipelineCreateInfoKHR-pLibraryInfo-03590", |
| 4929 | "vkCreateRayTracingPipelinesKHR: If pLibraryInfo is not NULL and its libraryCount member " |
| 4930 | "is greater than 0, its " |
| 4931 | "pLibraryInterface member must not be NULL."); |
| 4932 | } |
| 4933 | } |
| 4934 | } |
| 4935 | if (pCreateInfos[i].pLibraryInterface) { |
| 4936 | if (pCreateInfos[i].pLibraryInterface->maxPipelineRayHitAttributeSize > |
| 4937 | phys_dev_ext_props.ray_tracing_propsKHR.maxRayHitAttributeSize) { |
| 4938 | skip |= LogError(device, "VUID-VkRayTracingPipelineInterfaceCreateInfoKHR-maxPipelineRayHitAttributeSize-03605", |
| 4939 | "vkCreateRayTracingPipelinesKHR: maxPipelineRayHitAttributeSize must be less than or equal to " |
| 4940 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayHitAttributeSize."); |
| 4941 | } |
| 4942 | } |
| 4943 | if (deferredOperation != VK_NULL_HANDLE) { |
| 4944 | if (pCreateInfos[i].flags & VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT) { |
| 4945 | skip |= LogError(device, "VUID-vkCreateRayTracingPipelinesKHR-deferredOperation-03587", |
| 4946 | "vkCreateRayTracingPipelinesKHR: If deferredOperation is not VK_NULL_HANDLE, the flags member of " |
| 4947 | "elements of pCreateInfos must not include VK_PIPELINE_CREATE_EARLY_RETURN_ON_FAILURE_BIT_EXT."); |
sourav parmar | f4a7825 | 2020-04-10 13:04:21 -0700 | [diff] [blame] | 4948 | } |
| 4949 | } |
Jeff Bolz | 443c2ca | 2020-03-19 12:11:51 -0500 | [diff] [blame] | 4950 | } |
| 4951 | |
| 4952 | return skip; |
| 4953 | } |
| 4954 | |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4955 | #ifdef VK_USE_PLATFORM_WIN32_KHR |
| 4956 | bool StatelessValidation::PreCallValidateGetDeviceGroupSurfacePresentModes2EXT(VkDevice device, |
| 4957 | const VkPhysicalDeviceSurfaceInfo2KHR *pSurfaceInfo, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4958 | VkDeviceGroupPresentModeFlagsKHR *pModes) const { |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4959 | bool skip = false; |
| 4960 | if (!device_extensions.vk_khr_swapchain) |
| 4961 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SWAPCHAIN_EXTENSION_NAME); |
| 4962 | if (!device_extensions.vk_khr_get_surface_capabilities_2) |
| 4963 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
| 4964 | if (!device_extensions.vk_khr_surface) |
| 4965 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_SURFACE_EXTENSION_NAME); |
| 4966 | if (!device_extensions.vk_khr_get_physical_device_properties_2) |
| 4967 | skip |= |
| 4968 | OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_KHR_GET_PHYSICAL_DEVICE_PROPERTIES_2_EXTENSION_NAME); |
| 4969 | if (!device_extensions.vk_ext_full_screen_exclusive) |
| 4970 | skip |= OutputExtensionError("vkGetDeviceGroupSurfacePresentModes2EXT", VK_EXT_FULL_SCREEN_EXCLUSIVE_EXTENSION_NAME); |
| 4971 | skip |= validate_struct_type( |
| 4972 | "vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo", "VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR", |
| 4973 | pSurfaceInfo, VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SURFACE_INFO_2_KHR, true, |
| 4974 | "VUID-vkGetDeviceGroupSurfacePresentModes2EXT-pSurfaceInfo-parameter", "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-sType"); |
| 4975 | if (pSurfaceInfo != NULL) { |
| 4976 | const VkStructureType allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR[] = { |
| 4977 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_INFO_EXT, |
| 4978 | VK_STRUCTURE_TYPE_SURFACE_FULL_SCREEN_EXCLUSIVE_WIN32_INFO_EXT}; |
| 4979 | |
| 4980 | skip |= validate_struct_pnext("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->pNext", |
| 4981 | "VkSurfaceFullScreenExclusiveInfoEXT, VkSurfaceFullScreenExclusiveWin32InfoEXT", |
| 4982 | pSurfaceInfo->pNext, ARRAY_SIZE(allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR), |
| 4983 | allowed_structs_VkPhysicalDeviceSurfaceInfo2KHR, GeneratedVulkanHeaderVersion, |
sfricke-samsung | 32a2736 | 2020-02-28 09:06:42 -0800 | [diff] [blame] | 4984 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-pNext-pNext", |
| 4985 | "VUID-VkPhysicalDeviceSurfaceInfo2KHR-sType-unique"); |
Mike Schuchardt | 21638df | 2019-03-16 10:52:02 -0700 | [diff] [blame] | 4986 | |
| 4987 | skip |= validate_required_handle("vkGetDeviceGroupSurfacePresentModes2EXT", "pSurfaceInfo->surface", pSurfaceInfo->surface); |
| 4988 | } |
| 4989 | return skip; |
| 4990 | } |
| 4991 | #endif |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4992 | |
| 4993 | bool StatelessValidation::manual_PreCallValidateCreateFramebuffer(VkDevice device, const VkFramebufferCreateInfo *pCreateInfo, |
| 4994 | const VkAllocationCallbacks *pAllocator, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 4995 | VkFramebuffer *pFramebuffer) const { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4996 | // Validation for pAttachments which is excluded from the generated validation code due to a 'noautovalidity' tag in vk.xml |
| 4997 | bool skip = false; |
Mike Schuchardt | 2df0891 | 2020-12-15 16:28:09 -0800 | [diff] [blame] | 4998 | if ((pCreateInfo->flags & VK_FRAMEBUFFER_CREATE_IMAGELESS_BIT) == 0) { |
Tobias Hector | ebb855f | 2019-07-23 12:17:33 +0100 | [diff] [blame] | 4999 | skip |= validate_array("vkCreateFramebuffer", "attachmentCount", "pAttachments", pCreateInfo->attachmentCount, |
| 5000 | &pCreateInfo->pAttachments, false, true, kVUIDUndefined, kVUIDUndefined); |
| 5001 | } |
| 5002 | return skip; |
| 5003 | } |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 5004 | |
| 5005 | bool StatelessValidation::manual_PreCallValidateCmdSetLineStippleEXT(VkCommandBuffer commandBuffer, uint32_t lineStippleFactor, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5006 | uint16_t lineStipplePattern) const { |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 5007 | bool skip = false; |
| 5008 | |
| 5009 | if (lineStippleFactor < 1 || lineStippleFactor > 256) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5010 | skip |= LogError(commandBuffer, "VUID-vkCmdSetLineStippleEXT-lineStippleFactor-02776", |
| 5011 | "vkCmdSetLineStippleEXT::lineStippleFactor=%d is not in [1,256].", lineStippleFactor); |
Jeff Bolz | 8125a8b | 2019-08-16 16:29:45 -0500 | [diff] [blame] | 5012 | } |
| 5013 | |
| 5014 | return skip; |
| 5015 | } |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5016 | |
| 5017 | bool StatelessValidation::manual_PreCallValidateCmdBindIndexBuffer(VkCommandBuffer commandBuffer, VkBuffer buffer, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5018 | VkDeviceSize offset, VkIndexType indexType) const { |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5019 | bool skip = false; |
| 5020 | |
| 5021 | if (indexType == VK_INDEX_TYPE_NONE_NV) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5022 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02507", |
| 5023 | "vkCmdBindIndexBuffer() indexType must not be VK_INDEX_TYPE_NONE_NV."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5024 | } |
| 5025 | |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 5026 | const auto *index_type_uint8_features = lvl_find_in_chain<VkPhysicalDeviceIndexTypeUint8FeaturesEXT>(device_createinfo_pnext); |
Mark Lobodzinski | 804fde8 | 2020-05-08 07:49:25 -0600 | [diff] [blame] | 5027 | if (indexType == VK_INDEX_TYPE_UINT8_EXT && (!index_type_uint8_features || !index_type_uint8_features->indexTypeUint8)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5028 | skip |= LogError(commandBuffer, "VUID-vkCmdBindIndexBuffer-indexType-02765", |
| 5029 | "vkCmdBindIndexBuffer() indexType is VK_INDEX_TYPE_UINT8_EXT but indexTypeUint8 feature is not enabled."); |
Piers Daniell | 8fd03f5 | 2019-08-21 12:07:53 -0600 | [diff] [blame] | 5030 | } |
| 5031 | |
| 5032 | return skip; |
| 5033 | } |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5034 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 5035 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 5036 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 5037 | const VkDeviceSize *pOffsets) const { |
| 5038 | bool skip = false; |
| 5039 | if (firstBinding > device_limits.maxVertexInputBindings) { |
| 5040 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00624", |
| 5041 | "vkCmdBindVertexBuffers() firstBinding (%u) must be less than maxVertexInputBindings (%u)", firstBinding, |
| 5042 | device_limits.maxVertexInputBindings); |
| 5043 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 5044 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-firstBinding-00625", |
| 5045 | "vkCmdBindVertexBuffers() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 5046 | "maxVertexInputBindings (%u)", |
| 5047 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 5048 | } |
| 5049 | |
Jeff Bolz | 165818a | 2020-05-08 11:19:03 -0500 | [diff] [blame] | 5050 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5051 | if (pBuffers[i] == VK_NULL_HANDLE) { |
| 5052 | const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 5053 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 5054 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04001", |
| 5055 | "vkCmdBindVertexBuffers() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i); |
| 5056 | } else { |
| 5057 | if (pOffsets[i] != 0) { |
| 5058 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers-pBuffers-04002", |
| 5059 | "vkCmdBindVertexBuffers() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i); |
| 5060 | } |
| 5061 | } |
| 5062 | } |
| 5063 | } |
| 5064 | |
sfricke-samsung | 4ada8d4 | 2020-02-09 17:43:11 -0800 | [diff] [blame] | 5065 | return skip; |
| 5066 | } |
| 5067 | |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5068 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectNameEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5069 | const VkDebugUtilsObjectNameInfoEXT *pNameInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5070 | bool skip = false; |
| 5071 | if (pNameInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5072 | skip |= LogError(device, "VUID-VkDebugUtilsObjectNameInfoEXT-objectType-02589", |
| 5073 | "vkSetDebugUtilsObjectNameEXT() pNameInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5074 | } |
| 5075 | return skip; |
| 5076 | } |
| 5077 | |
| 5078 | bool StatelessValidation::manual_PreCallValidateSetDebugUtilsObjectTagEXT(VkDevice device, |
Jeff Bolz | 5c801d1 | 2019-10-09 10:38:45 -0500 | [diff] [blame] | 5079 | const VkDebugUtilsObjectTagInfoEXT *pTagInfo) const { |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5080 | bool skip = false; |
| 5081 | if (pTagInfo->objectType == VK_OBJECT_TYPE_UNKNOWN) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5082 | skip |= LogError(device, "VUID-VkDebugUtilsObjectTagInfoEXT-objectType-01908", |
| 5083 | "vkSetDebugUtilsObjectTagEXT() pTagInfo->objectType cannot be VK_OBJECT_TYPE_UNKNOWN."); |
Mark Lobodzinski | 8498840 | 2019-09-11 15:27:30 -0600 | [diff] [blame] | 5084 | } |
| 5085 | return skip; |
| 5086 | } |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5087 | |
| 5088 | bool StatelessValidation::manual_PreCallValidateAcquireNextImageKHR(VkDevice device, VkSwapchainKHR swapchain, uint64_t timeout, |
| 5089 | VkSemaphore semaphore, VkFence fence, |
| 5090 | uint32_t *pImageIndex) const { |
| 5091 | bool skip = false; |
| 5092 | |
| 5093 | if (semaphore == VK_NULL_HANDLE && fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5094 | skip |= LogError(swapchain, "VUID-vkAcquireNextImageKHR-semaphore-01780", |
| 5095 | "vkAcquireNextImageKHR: semaphore and fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5096 | } |
| 5097 | |
| 5098 | return skip; |
| 5099 | } |
| 5100 | |
| 5101 | bool StatelessValidation::manual_PreCallValidateAcquireNextImage2KHR(VkDevice device, const VkAcquireNextImageInfoKHR *pAcquireInfo, |
| 5102 | uint32_t *pImageIndex) const { |
| 5103 | bool skip = false; |
| 5104 | |
| 5105 | if (pAcquireInfo->semaphore == VK_NULL_HANDLE && pAcquireInfo->fence == VK_NULL_HANDLE) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5106 | skip |= LogError(pAcquireInfo->swapchain, "VUID-VkAcquireNextImageInfoKHR-semaphore-01782", |
| 5107 | "vkAcquireNextImage2KHR: pAcquireInfo->semaphore and pAcquireInfo->fence are both VK_NULL_HANDLE."); |
Petr Kraus | 3d72039 | 2019-11-13 02:52:39 +0100 | [diff] [blame] | 5108 | } |
| 5109 | |
| 5110 | return skip; |
| 5111 | } |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5112 | |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 5113 | bool StatelessValidation::manual_PreCallValidateCmdBindTransformFeedbackBuffersEXT(VkCommandBuffer commandBuffer, |
| 5114 | uint32_t firstBinding, uint32_t bindingCount, |
| 5115 | const VkBuffer *pBuffers, |
| 5116 | const VkDeviceSize *pOffsets, |
| 5117 | const VkDeviceSize *pSizes) const { |
| 5118 | bool skip = false; |
| 5119 | |
| 5120 | char const *const cmd_name = "CmdBindTransformFeedbackBuffersEXT"; |
| 5121 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5122 | if (pOffsets[i] & 3) { |
| 5123 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pOffsets-02359", |
| 5124 | "%s: pOffsets[%" PRIu32 "](0x%" PRIxLEAST64 ") is not a multiple of 4.", cmd_name, i, pOffsets[i]); |
| 5125 | } |
| 5126 | } |
| 5127 | |
| 5128 | if (firstBinding >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5129 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02356", |
| 5130 | "%s: The firstBinding(%" PRIu32 |
| 5131 | ") index is greater than or equal to " |
| 5132 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5133 | cmd_name, firstBinding, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5134 | } |
| 5135 | |
| 5136 | if (firstBinding + bindingCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5137 | skip |= |
| 5138 | LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-firstBinding-02357", |
| 5139 | "%s: The sum of firstBinding(%" PRIu32 ") and bindCount(%" PRIu32 |
| 5140 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5141 | cmd_name, firstBinding, bindingCount, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5142 | } |
| 5143 | |
| 5144 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5145 | // pSizes is optional and may be nullptr. |
| 5146 | if (pSizes != nullptr) { |
| 5147 | if (pSizes[i] != VK_WHOLE_SIZE && |
| 5148 | pSizes[i] > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferSize) { |
| 5149 | skip |= LogError(commandBuffer, "VUID-vkCmdBindTransformFeedbackBuffersEXT-pSize-02361", |
| 5150 | "%s: pSizes[%" PRIu32 "] (0x%" PRIxLEAST64 |
| 5151 | ") is not VK_WHOLE_SIZE and is greater than " |
| 5152 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBufferSize.", |
| 5153 | cmd_name, i, pSizes[i]); |
| 5154 | } |
| 5155 | } |
| 5156 | } |
| 5157 | |
| 5158 | return skip; |
| 5159 | } |
| 5160 | |
| 5161 | bool StatelessValidation::manual_PreCallValidateCmdBeginTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 5162 | uint32_t firstCounterBuffer, |
| 5163 | uint32_t counterBufferCount, |
| 5164 | const VkBuffer *pCounterBuffers, |
| 5165 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 5166 | bool skip = false; |
| 5167 | |
| 5168 | char const *const cmd_name = "CmdBeginTransformFeedbackEXT"; |
| 5169 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5170 | skip |= LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02368", |
| 5171 | "%s: The firstCounterBuffer(%" PRIu32 |
| 5172 | ") index is greater than or equal to " |
| 5173 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5174 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5175 | } |
| 5176 | |
| 5177 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5178 | skip |= |
| 5179 | LogError(commandBuffer, "VUID-vkCmdBeginTransformFeedbackEXT-firstCounterBuffer-02369", |
| 5180 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 5181 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5182 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 5183 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5184 | } |
| 5185 | |
| 5186 | return skip; |
| 5187 | } |
| 5188 | |
| 5189 | bool StatelessValidation::manual_PreCallValidateCmdEndTransformFeedbackEXT(VkCommandBuffer commandBuffer, |
| 5190 | uint32_t firstCounterBuffer, uint32_t counterBufferCount, |
| 5191 | const VkBuffer *pCounterBuffers, |
| 5192 | const VkDeviceSize *pCounterBufferOffsets) const { |
| 5193 | bool skip = false; |
| 5194 | |
| 5195 | char const *const cmd_name = "CmdEndTransformFeedbackEXT"; |
| 5196 | if (firstCounterBuffer >= phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5197 | skip |= LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02376", |
| 5198 | "%s: The firstCounterBuffer(%" PRIu32 |
| 5199 | ") index is greater than or equal to " |
| 5200 | "VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5201 | cmd_name, firstCounterBuffer, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5202 | } |
| 5203 | |
| 5204 | if (firstCounterBuffer + counterBufferCount > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers) { |
| 5205 | skip |= |
| 5206 | LogError(commandBuffer, "VUID-vkCmdEndTransformFeedbackEXT-firstCounterBuffer-02377", |
| 5207 | "%s: The sum of firstCounterBuffer(%" PRIu32 ") and counterBufferCount(%" PRIu32 |
| 5208 | ") is greater than VkPhysicalDeviceTransformFeedbackPropertiesEXT::maxTransformFeedbackBuffers(%" PRIu32 ").", |
| 5209 | cmd_name, firstCounterBuffer, counterBufferCount, |
| 5210 | phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBuffers); |
| 5211 | } |
| 5212 | |
| 5213 | return skip; |
| 5214 | } |
| 5215 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5216 | bool StatelessValidation::manual_PreCallValidateCmdDrawIndirectByteCountEXT(VkCommandBuffer commandBuffer, uint32_t instanceCount, |
| 5217 | uint32_t firstInstance, VkBuffer counterBuffer, |
| 5218 | VkDeviceSize counterBufferOffset, |
| 5219 | uint32_t counterOffset, uint32_t vertexStride) const { |
| 5220 | bool skip = false; |
| 5221 | |
| 5222 | if ((vertexStride <= 0) || (vertexStride > phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5223 | skip |= LogError( |
| 5224 | counterBuffer, "VUID-vkCmdDrawIndirectByteCountEXT-vertexStride-02289", |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5225 | "vkCmdDrawIndirectByteCountEXT: vertexStride (%d) must be between 0 and maxTransformFeedbackBufferDataStride (%d).", |
| 5226 | vertexStride, phys_dev_ext_props.transform_feedback_props.maxTransformFeedbackBufferDataStride); |
| 5227 | } |
| 5228 | |
sfricke-samsung | d5e9adb | 2020-10-26 03:59:29 -0700 | [diff] [blame] | 5229 | if ((counterOffset % 4) != 0) { |
| 5230 | // TODO - Update when header are updated |
| 5231 | skip |= LogError(commandBuffer, "UNASSIGNED-vkCmdDrawIndirectByteCountEXT-offset", |
| 5232 | "vkCmdDrawIndirectByteCountEXT(): offset (%" PRIu64 ") must be a multiple of 4.", counterOffset); |
| 5233 | } |
| 5234 | |
Mark Lobodzinski | 953b7bc | 2019-12-19 13:50:10 -0700 | [diff] [blame] | 5235 | return skip; |
| 5236 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5237 | |
| 5238 | bool StatelessValidation::ValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 5239 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 5240 | const VkAllocationCallbacks *pAllocator, |
| 5241 | VkSamplerYcbcrConversion *pYcbcrConversion, |
| 5242 | const char *apiName) const { |
| 5243 | bool skip = false; |
| 5244 | |
| 5245 | // Check samplerYcbcrConversion feature is set |
Tony-LunarG | 6c3c545 | 2019-12-13 10:37:38 -0700 | [diff] [blame] | 5246 | const auto *ycbcr_features = lvl_find_in_chain<VkPhysicalDeviceSamplerYcbcrConversionFeatures>(device_createinfo_pnext); |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5247 | if ((ycbcr_features == nullptr) || (ycbcr_features->samplerYcbcrConversion == VK_FALSE)) { |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 5248 | const auto *vulkan_11_features = lvl_find_in_chain<VkPhysicalDeviceVulkan11Features>(device_createinfo_pnext); |
| 5249 | if ((vulkan_11_features == nullptr) || (vulkan_11_features->samplerYcbcrConversion == VK_FALSE)) { |
| 5250 | skip |= LogError(device, "VUID-vkCreateSamplerYcbcrConversion-None-01648", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5251 | "%s: samplerYcbcrConversion must be enabled.", apiName); |
Ricardo Garcia | 3a34ffb | 2020-06-24 09:36:18 +0200 | [diff] [blame] | 5252 | } |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5253 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5254 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5255 | #ifdef VK_USE_PLATFORM_ANDROID_KHR |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5256 | const VkExternalFormatANDROID *external_format_android = lvl_find_in_chain<VkExternalFormatANDROID>(pCreateInfo); |
| 5257 | const bool is_external_format = external_format_android != nullptr && external_format_android->externalFormat != 0; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5258 | #else |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5259 | const bool is_external_format = false; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5260 | #endif |
| 5261 | |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5262 | const VkFormat format = pCreateInfo->format; |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5263 | |
| 5264 | // If there is a VkExternalFormatANDROID with externalFormat != 0, the value of components is ignored. |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5265 | if (!is_external_format) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5266 | const VkComponentMapping components = pCreateInfo->components; |
| 5267 | // XChroma Subsampled is same as "the format has a _422 or _420 suffix" from spec |
| 5268 | if (FormatIsXChromaSubsampled(format) == true) { |
| 5269 | if ((components.g != VK_COMPONENT_SWIZZLE_G) && (components.g != VK_COMPONENT_SWIZZLE_IDENTITY)) { |
| 5270 | skip |= |
| 5271 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02581", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5272 | "%s: When using a XChroma subsampled format (%s) the components.g needs to be VK_COMPONENT_SWIZZLE_G " |
| 5273 | "or VK_COMPONENT_SWIZZLE_IDENTITY, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5274 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.g)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5275 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5276 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5277 | if ((components.a != VK_COMPONENT_SWIZZLE_A) && (components.a != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 5278 | (components.a != VK_COMPONENT_SWIZZLE_ONE) && (components.a != VK_COMPONENT_SWIZZLE_ZERO)) { |
| 5279 | skip |= LogError( |
| 5280 | device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02582", |
| 5281 | "%s: When using a XChroma subsampled format (%s) the components.a needs to be VK_COMPONENT_SWIZZLE_A or " |
| 5282 | "VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_ONE or VK_COMPONENT_SWIZZLE_ZERO, but is %s.", |
| 5283 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.a)); |
| 5284 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5285 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5286 | if ((components.r != VK_COMPONENT_SWIZZLE_R) && (components.r != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 5287 | (components.r != VK_COMPONENT_SWIZZLE_B)) { |
| 5288 | skip |= |
| 5289 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02583", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5290 | "%s: When using a XChroma subsampled format (%s) the components.r needs to be VK_COMPONENT_SWIZZLE_R " |
| 5291 | "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_B, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5292 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5293 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5294 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5295 | if ((components.b != VK_COMPONENT_SWIZZLE_B) && (components.b != VK_COMPONENT_SWIZZLE_IDENTITY) && |
| 5296 | (components.b != VK_COMPONENT_SWIZZLE_R)) { |
| 5297 | skip |= |
| 5298 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02584", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5299 | "%s: When using a XChroma subsampled format (%s) the components.b needs to be VK_COMPONENT_SWIZZLE_B " |
| 5300 | "or VK_COMPONENT_SWIZZLE_IDENTITY or VK_COMPONENT_SWIZZLE_R, but is %s.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5301 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5302 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5303 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5304 | // If one is identity, both need to be |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5305 | const bool r_identity = ((components.r == VK_COMPONENT_SWIZZLE_R) || (components.r == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 5306 | const bool b_identity = ((components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY)); |
| 5307 | if ((r_identity != b_identity) && ((r_identity == true) || (b_identity == true))) { |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5308 | skip |= |
| 5309 | LogError(device, "VUID-VkSamplerYcbcrConversionCreateInfo-components-02585", |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5310 | "%s: When using a XChroma subsampled format (%s) if either the components.r (%s) or components.b (%s) " |
| 5311 | "are an identity swizzle, then both need to be an identity swizzle.", |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5312 | apiName, string_VkFormat(format), string_VkComponentSwizzle(components.r), |
| 5313 | string_VkComponentSwizzle(components.b)); |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5314 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5315 | } |
| 5316 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5317 | if (pCreateInfo->ycbcrModel != VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY) { |
| 5318 | // Checks same VU multiple ways in order to give a more useful error message |
| 5319 | const char *vuid = "VUID-VkSamplerYcbcrConversionCreateInfo-ycbcrModel-01655"; |
| 5320 | if ((components.r == VK_COMPONENT_SWIZZLE_ONE) || (components.r == VK_COMPONENT_SWIZZLE_ZERO) || |
| 5321 | (components.g == VK_COMPONENT_SWIZZLE_ONE) || (components.g == VK_COMPONENT_SWIZZLE_ZERO) || |
| 5322 | (components.b == VK_COMPONENT_SWIZZLE_ONE) || (components.b == VK_COMPONENT_SWIZZLE_ZERO)) { |
| 5323 | skip |= LogError( |
| 5324 | device, vuid, |
| 5325 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5326 | "components.g (%s), nor components.b (%s) can't be VK_COMPONENT_SWIZZLE_ZERO or VK_COMPONENT_SWIZZLE_ONE.", |
| 5327 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5328 | string_VkComponentSwizzle(components.b)); |
| 5329 | } |
sfricke-samsung | 1a72f94 | 2020-07-25 12:09:18 -0700 | [diff] [blame] | 5330 | |
Benjamin Thaut | d0bc2a9 | 2020-08-25 17:09:09 +0200 | [diff] [blame] | 5331 | // "must not correspond to a channel which contains zero or one as a consequence of conversion to RGBA" |
| 5332 | // 4 channel format = no issue |
| 5333 | // 3 = no [a] |
| 5334 | // 2 = no [b,a] |
| 5335 | // 1 = no [g,b,a] |
| 5336 | // depth/stencil = no [g,b,a] (shouldn't ever occur, but no VU preventing it) |
| 5337 | const uint32_t channels = (FormatIsDepthOrStencil(format) == true) ? 1 : FormatChannelCount(format); |
| 5338 | |
| 5339 | if ((channels < 4) && ((components.r == VK_COMPONENT_SWIZZLE_A) || (components.g == VK_COMPONENT_SWIZZLE_A) || |
| 5340 | (components.b == VK_COMPONENT_SWIZZLE_A))) { |
| 5341 | skip |= LogError(device, vuid, |
| 5342 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5343 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_A.", |
| 5344 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5345 | string_VkComponentSwizzle(components.b)); |
| 5346 | } else if ((channels < 3) && |
| 5347 | ((components.r == VK_COMPONENT_SWIZZLE_B) || (components.g == VK_COMPONENT_SWIZZLE_B) || |
| 5348 | (components.b == VK_COMPONENT_SWIZZLE_B) || (components.b == VK_COMPONENT_SWIZZLE_IDENTITY))) { |
| 5349 | skip |= LogError(device, vuid, |
| 5350 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5351 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_B " |
| 5352 | "(components.b also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 5353 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5354 | string_VkComponentSwizzle(components.b)); |
| 5355 | } else if ((channels < 2) && |
| 5356 | ((components.r == VK_COMPONENT_SWIZZLE_G) || (components.g == VK_COMPONENT_SWIZZLE_G) || |
| 5357 | (components.g == VK_COMPONENT_SWIZZLE_IDENTITY) || (components.b == VK_COMPONENT_SWIZZLE_G))) { |
| 5358 | skip |= LogError(device, vuid, |
| 5359 | "%s: The ycbcrModel is not VK_SAMPLER_YCBCR_MODEL_CONVERSION_RGB_IDENTITY so components.r (%s), " |
| 5360 | "components.g (%s), or components.b (%s) can't be VK_COMPONENT_SWIZZLE_G " |
| 5361 | "(components.g also can't be VK_COMPONENT_SWIZZLE_IDENTITY).", |
| 5362 | apiName, string_VkComponentSwizzle(components.r), string_VkComponentSwizzle(components.g), |
| 5363 | string_VkComponentSwizzle(components.b)); |
| 5364 | } |
sfricke-samsung | 83d9812 | 2020-07-04 06:21:15 -0700 | [diff] [blame] | 5365 | } |
| 5366 | } |
| 5367 | |
sfricke-samsung | 11ea8ed | 2020-01-07 22:24:56 -0800 | [diff] [blame] | 5368 | return skip; |
| 5369 | } |
| 5370 | |
| 5371 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversion(VkDevice device, |
| 5372 | const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, |
| 5373 | const VkAllocationCallbacks *pAllocator, |
| 5374 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 5375 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 5376 | "vkCreateSamplerYcbcrConversion"); |
| 5377 | } |
| 5378 | |
| 5379 | bool StatelessValidation::manual_PreCallValidateCreateSamplerYcbcrConversionKHR( |
| 5380 | VkDevice device, const VkSamplerYcbcrConversionCreateInfo *pCreateInfo, const VkAllocationCallbacks *pAllocator, |
| 5381 | VkSamplerYcbcrConversion *pYcbcrConversion) const { |
| 5382 | return ValidateCreateSamplerYcbcrConversion(device, pCreateInfo, pAllocator, pYcbcrConversion, |
| 5383 | "vkCreateSamplerYcbcrConversionKHR"); |
| 5384 | } |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 5385 | |
| 5386 | bool StatelessValidation::manual_PreCallValidateImportSemaphoreFdKHR( |
| 5387 | VkDevice device, const VkImportSemaphoreFdInfoKHR *pImportSemaphoreFdInfo) const { |
| 5388 | bool skip = false; |
| 5389 | VkExternalSemaphoreHandleTypeFlags supported_handle_types = |
| 5390 | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_OPAQUE_FD_BIT | VK_EXTERNAL_SEMAPHORE_HANDLE_TYPE_SYNC_FD_BIT; |
| 5391 | |
| 5392 | if (0 == (pImportSemaphoreFdInfo->handleType & supported_handle_types)) { |
Mark Lobodzinski | 5d8244a | 2020-01-23 13:00:43 -0700 | [diff] [blame] | 5393 | skip |= LogError(device, "VUID-VkImportSemaphoreFdInfoKHR-handleType-01143", |
| 5394 | "vkImportSemaphoreFdKHR() to semaphore %s handleType %s is not one of the supported handleTypes (%s).", |
| 5395 | report_data->FormatHandle(pImportSemaphoreFdInfo->semaphore).c_str(), |
| 5396 | string_VkExternalSemaphoreHandleTypeFlagBits(pImportSemaphoreFdInfo->handleType), |
| 5397 | string_VkExternalSemaphoreHandleTypeFlags(supported_handle_types).c_str()); |
sfricke-samsung | 1708a8c | 2020-02-10 00:35:06 -0800 | [diff] [blame] | 5398 | } |
| 5399 | return skip; |
| 5400 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5401 | |
| 5402 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureToMemoryKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5403 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5404 | bool skip = false; |
| 5405 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 5406 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 5407 | "vkCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 5408 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5409 | const auto *acc_struct_features = lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
| 5410 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 5411 | skip |= LogError( |
| 5412 | device, "VUID-vkCopyAccelerationStructureToMemoryKHR-accelerationStructureHostCommands-03584", |
| 5413 | "vkCopyAccelerationStructureToMemoryKHR: The " |
| 5414 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 5415 | } |
| 5416 | skip |= validate_required_pointer("vkCopyAccelerationStructureToMemoryKHR", "pInfo->dst.hostAddress", pInfo->dst.hostAddress, |
| 5417 | "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03732"); |
| 5418 | if (SafeModulo((VkDeviceSize)pInfo->dst.hostAddress, 16) != 0) { |
| 5419 | skip |= LogError(device, "VUID-vkCopyAccelerationStructureToMemoryKHR-pInfo-03751", |
| 5420 | "vkCopyAccelerationStructureToMemoryKHR(): pInfo->dst.hostAddress must be aligned to 16 bytes."); |
| 5421 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5422 | return skip; |
| 5423 | } |
| 5424 | |
| 5425 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureToMemoryKHR( |
| 5426 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureToMemoryInfoKHR *pInfo) const { |
| 5427 | bool skip = false; |
| 5428 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR) { |
| 5429 | skip |= // to update VUID to VkCmdCopyAccelerationStructureToMemoryInfoKHR after spec update |
| 5430 | LogError(commandBuffer, "VUID-VkCopyAccelerationStructureToMemoryInfoKHR-mode-03412", |
| 5431 | "vkCmdCopyAccelerationStructureToMemoryKHR: mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_SERIALIZE_KHR."); |
| 5432 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5433 | if (SafeModulo(pInfo->dst.deviceAddress, 256) != 0) { |
| 5434 | skip |= LogError(device, "VUID-vkCmdCopyAccelerationStructureToMemoryKHR-pInfo-03740", |
| 5435 | "vkCmdCopyAccelerationStructureToMemoryKHR(): pInfo->dst.deviceAddress must be aligned to 256 bytes.", |
| 5436 | pInfo->dst.deviceAddress); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5437 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5438 | return skip; |
| 5439 | } |
| 5440 | |
| 5441 | bool StatelessValidation::ValidateCopyAccelerationStructureInfoKHR(const VkCopyAccelerationStructureInfoKHR *pInfo, |
| 5442 | const char *api_name) const { |
| 5443 | bool skip = false; |
| 5444 | if (!(pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR || |
| 5445 | pInfo->mode == VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR)) { |
| 5446 | skip |= LogError(device, "VUID-VkCopyAccelerationStructureInfoKHR-mode-03410", |
| 5447 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_COMPACT_KHR" |
| 5448 | "or VK_COPY_ACCELERATION_STRUCTURE_MODE_CLONE_KHR.", |
| 5449 | api_name); |
| 5450 | } |
| 5451 | return skip; |
| 5452 | } |
| 5453 | |
| 5454 | bool StatelessValidation::manual_PreCallValidateCopyAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5455 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5456 | bool skip = false; |
| 5457 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCopyAccelerationStructureKHR()"); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5458 | const auto *acc_struct_features = lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
| 5459 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5460 | skip |= LogError( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5461 | device, "VUID-vkCopyAccelerationStructureKHR-accelerationStructureHostCommands-03582", |
| 5462 | "vkCopyAccelerationStructureKHR: The " |
| 5463 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5464 | } |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5465 | return skip; |
| 5466 | } |
| 5467 | |
| 5468 | bool StatelessValidation::manual_PreCallValidateCmdCopyAccelerationStructureKHR( |
| 5469 | VkCommandBuffer commandBuffer, const VkCopyAccelerationStructureInfoKHR *pInfo) const { |
| 5470 | bool skip = false; |
| 5471 | skip |= ValidateCopyAccelerationStructureInfoKHR(pInfo, "vkCmdCopyAccelerationStructureKHR()"); |
| 5472 | return skip; |
| 5473 | } |
| 5474 | |
| 5475 | bool StatelessValidation::ValidateCopyMemoryToAccelerationStructureInfoKHR(const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo, |
Mark Lobodzinski | aad69e4 | 2020-05-12 08:44:21 -0600 | [diff] [blame] | 5476 | const char *api_name, bool is_cmd) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5477 | bool skip = false; |
| 5478 | if (pInfo->mode != VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR) { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5479 | skip |= LogError(device, |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5480 | "VUID-VkCopyMemoryToAccelerationStructureInfoKHR-mode-03413", |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5481 | "(%s): mode must be VK_COPY_ACCELERATION_STRUCTURE_MODE_DESERIALIZE_KHR.", api_name); |
| 5482 | } |
| 5483 | return skip; |
| 5484 | } |
| 5485 | |
| 5486 | bool StatelessValidation::manual_PreCallValidateCopyMemoryToAccelerationStructureKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5487 | VkDevice device, VkDeferredOperationKHR deferredOperation, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5488 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5489 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCopyMemoryToAccelerationStructureKHR()", true); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5490 | const auto *acc_struct_features = lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
| 5491 | if (!acc_struct_features || acc_struct_features->accelerationStructureHostCommands == VK_FALSE) { |
| 5492 | skip |= LogError( |
| 5493 | device, "VUID-vkCopyMemoryToAccelerationStructureKHR-accelerationStructureHostCommands-03583", |
| 5494 | "vkCopyMemoryToAccelerationStructureKHR: The " |
| 5495 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5496 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5497 | skip |= validate_required_pointer("vkCopyMemoryToAccelerationStructureKHR", "pInfo->src.hostAddress", pInfo->src.hostAddress, |
| 5498 | "VUID-vkCopyMemoryToAccelerationStructureKHR-pInfo-03729"); |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5499 | return skip; |
| 5500 | } |
Jeremy Hayes | 9bda85a | 2020-05-21 16:36:17 -0600 | [diff] [blame] | 5501 | |
sourav parmar | a96ab1a | 2020-04-25 16:28:23 -0700 | [diff] [blame] | 5502 | bool StatelessValidation::manual_PreCallValidateCmdCopyMemoryToAccelerationStructureKHR( |
| 5503 | VkCommandBuffer commandBuffer, const VkCopyMemoryToAccelerationStructureInfoKHR *pInfo) const { |
| 5504 | bool skip = false; |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5505 | skip |= ValidateCopyMemoryToAccelerationStructureInfoKHR(pInfo, "vkCmdCopyMemoryToAccelerationStructureKHR()", false); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5506 | if (SafeModulo(pInfo->src.deviceAddress, 256) != 0) { |
| 5507 | skip |= LogError(device, "VUID-vkCmdCopyMemoryToAccelerationStructureKHR-pInfo-03743", |
| 5508 | "vkCmdCopyMemoryToAccelerationStructureKHR(): pInfo->src.deviceAddress must be aligned to 256 bytes.", |
| 5509 | pInfo->src.deviceAddress); |
| 5510 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5511 | return skip; |
| 5512 | } |
| 5513 | bool StatelessValidation::manual_PreCallValidateCmdWriteAccelerationStructuresPropertiesKHR( |
| 5514 | VkCommandBuffer commandBuffer, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 5515 | VkQueryType queryType, VkQueryPool queryPool, uint32_t firstQuery) const { |
| 5516 | bool skip = false; |
| 5517 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 5518 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 5519 | skip |= LogError(device, "VUID-vkCmdWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 5520 | "vkCmdWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 5521 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 5522 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 5523 | } |
| 5524 | return skip; |
| 5525 | } |
| 5526 | bool StatelessValidation::manual_PreCallValidateWriteAccelerationStructuresPropertiesKHR( |
| 5527 | VkDevice device, uint32_t accelerationStructureCount, const VkAccelerationStructureKHR *pAccelerationStructures, |
| 5528 | VkQueryType queryType, size_t dataSize, void *pData, size_t stride) const { |
| 5529 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5530 | const auto *acc_structure_features = |
| 5531 | lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
| 5532 | if (!acc_structure_features || acc_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 5533 | skip |= LogError( |
| 5534 | device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-accelerationStructureHostCommands-03585", |
| 5535 | "vkCmdWriteAccelerationStructuresPropertiesKHR: The " |
| 5536 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled."); |
| 5537 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5538 | if (dataSize < accelerationStructureCount * stride) { |
| 5539 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-dataSize-03452", |
| 5540 | "vkWriteAccelerationStructuresPropertiesKHR: dataSize (%zu) must be greater than or equal to " |
| 5541 | "accelerationStructureCount (%d) *stride(%zu).", |
| 5542 | dataSize, accelerationStructureCount, stride); |
| 5543 | } |
| 5544 | if (!(queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR || |
| 5545 | queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR)) { |
| 5546 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03432", |
| 5547 | "vkWriteAccelerationStructuresPropertiesKHR: queryType must be " |
| 5548 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR or " |
| 5549 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR."); |
| 5550 | } |
| 5551 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR) { |
| 5552 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 5553 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03448", |
| 5554 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 5555 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_COMPACTED_SIZE_KHR," |
| 5556 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 5557 | stride); |
| 5558 | } |
| 5559 | } |
| 5560 | if (queryType == VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR) { |
| 5561 | if (SafeModulo(stride, sizeof(VkDeviceSize)) != 0) { |
| 5562 | skip |= LogError(device, "VUID-vkWriteAccelerationStructuresPropertiesKHR-queryType-03450", |
| 5563 | "vkWriteAccelerationStructuresPropertiesKHR: If queryType is " |
| 5564 | "VK_QUERY_TYPE_ACCELERATION_STRUCTURE_SERIALIZATION_SIZE_KHR," |
| 5565 | "then stride (%zu) must be a multiple of the size of VkDeviceSize", |
| 5566 | stride); |
| 5567 | } |
| 5568 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5569 | return skip; |
| 5570 | } |
| 5571 | bool StatelessValidation::manual_PreCallValidateGetRayTracingCaptureReplayShaderGroupHandlesKHR( |
| 5572 | VkDevice device, VkPipeline pipeline, uint32_t firstGroup, uint32_t groupCount, size_t dataSize, void *pData) const { |
| 5573 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5574 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
| 5575 | if (!raytracing_features || raytracing_features->rayTracingPipelineShaderGroupHandleCaptureReplay == VK_FALSE) { |
| 5576 | skip |= LogError( |
| 5577 | device, "VUID-vkGetRayTracingCaptureReplayShaderGroupHandlesKHR-rayTracingPipelineShaderGroupHandleCaptureReplay-03606", |
| 5578 | "vkGetRayTracingCaptureReplayShaderGroupHandlesKHR:VkPhysicalDeviceRayTracingPipelineFeaturesKHR::" |
| 5579 | "rayTracingPipelineShaderGroupHandleCaptureReplay must be enabled to call this function."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5580 | } |
| 5581 | return skip; |
| 5582 | } |
| 5583 | |
| 5584 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysKHR(VkCommandBuffer commandBuffer, |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5585 | const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 5586 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, |
| 5587 | const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 5588 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5589 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 5590 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5591 | // RayGen |
| 5592 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 5593 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-size-04023", |
| 5594 | "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5595 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5596 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 5597 | 0) { |
| 5598 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pRayGenShaderBindingTable-03682", |
| 5599 | "vkCmdTraceRaysKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 5600 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5601 | } |
| 5602 | // Callable |
| 5603 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5604 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03694", |
| 5605 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 5606 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5607 | } |
| 5608 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5609 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04041", |
| 5610 | "vkCmdTraceRaysKHR: The stride member of pCallableShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5611 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 5612 | } |
| 5613 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 5614 | 0) { |
| 5615 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pCallableShaderBindingTable-03693", |
| 5616 | "vkCmdTraceRaysKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 5617 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5618 | } |
| 5619 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5620 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5621 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03690", |
| 5622 | "vkCmdTraceRaysKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 5623 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5624 | } |
| 5625 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5626 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5627 | "vkCmdTraceRaysKHR: TThe stride member of pHitShaderBindingTable must be less than or equal to " |
| 5628 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5629 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5630 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5631 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pHitShaderBindingTable-03689", |
| 5632 | "vkCmdTraceRaysKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 5633 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5634 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5635 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5636 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5637 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-03686", |
| 5638 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be a multiple of " |
| 5639 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5640 | } |
| 5641 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5642 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-stride-04029", |
| 5643 | "vkCmdTraceRaysKHR: The stride member of pMissShaderBindingTable must be" |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5644 | "less than or equal to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 5645 | } |
| 5646 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5647 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-pMissShaderBindingTable-03685", |
| 5648 | "vkCmdTraceRaysKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 5649 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5650 | } |
| 5651 | if (width * depth * height > phys_dev_ext_props.ray_tracing_propsKHR.maxRayDispatchInvocationCount) { |
| 5652 | skip |= LogError(device, "VUID-vkCmdTraceRaysKHR-width-03629", |
| 5653 | "vkCmdTraceRaysKHR: width {times} height {times} depth must be less than or equal to " |
| 5654 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxRayDispatchInvocationCount"); |
| 5655 | } |
| 5656 | if (width > device_limits.maxComputeWorkGroupCount[0] * device_limits.maxComputeWorkGroupSize[0]) { |
| 5657 | skip |= |
| 5658 | LogError(device, "VUID-vkCmdTraceRaysKHR-width-03626", |
| 5659 | "vkCmdTraceRaysKHR: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[0] " |
| 5660 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[0]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5661 | } |
| 5662 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5663 | if (height > device_limits.maxComputeWorkGroupCount[1] * device_limits.maxComputeWorkGroupSize[1]) { |
| 5664 | skip |= |
| 5665 | LogError(device, "VUID-vkCmdTraceRaysKHR-height-03627", |
| 5666 | "vkCmdTraceRaysKHR: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1] " |
| 5667 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[1]"); |
| 5668 | } |
| 5669 | |
| 5670 | if (depth > device_limits.maxComputeWorkGroupCount[2] * device_limits.maxComputeWorkGroupSize[2]) { |
| 5671 | skip |= |
| 5672 | LogError(device, "VUID-vkCmdTraceRaysKHR-depth-03628", |
| 5673 | "vkCmdTraceRaysKHR: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2] " |
| 5674 | "{times} VkPhysicalDeviceLimits::maxComputeWorkGroupSize[2]"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5675 | } |
| 5676 | return skip; |
| 5677 | } |
| 5678 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5679 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysIndirectKHR( |
| 5680 | VkCommandBuffer commandBuffer, const VkStridedDeviceAddressRegionKHR *pRaygenShaderBindingTable, |
| 5681 | const VkStridedDeviceAddressRegionKHR *pMissShaderBindingTable, const VkStridedDeviceAddressRegionKHR *pHitShaderBindingTable, |
| 5682 | const VkStridedDeviceAddressRegionKHR *pCallableShaderBindingTable, VkDeviceAddress indirectDeviceAddress) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5683 | bool skip = false; |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5684 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
| 5685 | if (!raytracing_features || raytracing_features->rayTracingPipelineTraceRaysIndirect == VK_FALSE) { |
| 5686 | skip |= LogError( |
| 5687 | device, "VUID-vkCmdTraceRaysIndirectKHR-rayTracingPipelineTraceRaysIndirect-03637", |
| 5688 | "vkCmdTraceRaysIndirectKHR: the VkPhysicalDeviceRayTracingPipelineFeaturesKHR::rayTracingPipelineTraceRaysIndirect " |
| 5689 | "feature must be enabled."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5690 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5691 | // RayGen |
| 5692 | if (pRaygenShaderBindingTable->size != pRaygenShaderBindingTable->stride) { |
| 5693 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-size-04023", |
| 5694 | "vkCmdTraceRaysKHR: The size member of pRayGenShaderBindingTable must be equal to its stride member"); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5695 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5696 | if (SafeModulo(pRaygenShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 5697 | 0) { |
| 5698 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pRayGenShaderBindingTable-03682", |
| 5699 | "vkCmdTraceRaysIndirectKHR: pRaygenShaderBindingTable->deviceAddress must be a multiple of " |
| 5700 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5701 | } |
| 5702 | // Callabe |
| 5703 | if (SafeModulo(pCallableShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5704 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03694", |
| 5705 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be a multiple of " |
| 5706 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5707 | } |
| 5708 | if (pCallableShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5709 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04041", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5710 | "vkCmdTraceRaysIndirectKHR: The stride member of pCallableShaderBindingTable must be less than or equal " |
| 5711 | "to VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 5712 | } |
| 5713 | if (SafeModulo(pCallableShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != |
| 5714 | 0) { |
| 5715 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pCallableShaderBindingTable-03693", |
| 5716 | "vkCmdTraceRaysIndirectKHR: pCallableShaderBindingTable->deviceAddress must be a multiple of " |
| 5717 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5718 | } |
| 5719 | // hitShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5720 | if (SafeModulo(pHitShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5721 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03690", |
| 5722 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be a multiple of " |
| 5723 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5724 | } |
| 5725 | if (pHitShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5726 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04035", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5727 | "vkCmdTraceRaysIndirectKHR: The stride member of pHitShaderBindingTable must be less than or equal to " |
| 5728 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5729 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5730 | if (SafeModulo(pHitShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5731 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pHitShaderBindingTable-03689", |
| 5732 | "vkCmdTraceRaysIndirectKHR: pHitShaderBindingTable->deviceAddress must be a multiple of " |
| 5733 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
| 5734 | } |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5735 | // missShader |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5736 | if (SafeModulo(pMissShaderBindingTable->stride, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupHandleAlignment) != 0) { |
| 5737 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-03686", |
| 5738 | "vkCmdTraceRaysIndirectKHR:The stride member of pMissShaderBindingTable must be a multiple of " |
| 5739 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupHandleAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5740 | } |
| 5741 | if (pMissShaderBindingTable->stride > phys_dev_ext_props.ray_tracing_propsKHR.maxShaderGroupStride) { |
| 5742 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-stride-04029", |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5743 | "vkCmdTraceRaysIndirectKHR: The stride member of pMissShaderBindingTable must be less than or equal to " |
| 5744 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::maxShaderGroupStride."); |
| 5745 | } |
| 5746 | if (SafeModulo(pMissShaderBindingTable->deviceAddress, phys_dev_ext_props.ray_tracing_propsKHR.shaderGroupBaseAlignment) != 0) { |
| 5747 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-pMissShaderBindingTable-03685", |
| 5748 | "vkCmdTraceRaysIndirectKHR: pMissShaderBindingTable->deviceAddress must be a multiple of " |
| 5749 | "VkPhysicalDeviceRayTracingPipelinePropertiesKHR::shaderGroupBaseAlignment."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5750 | } |
| 5751 | |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5752 | if (SafeModulo(indirectDeviceAddress, 4) != 0) { |
| 5753 | skip |= LogError(device, "VUID-vkCmdTraceRaysIndirectKHR-indirectDeviceAddress-03634", |
| 5754 | "vkCmdTraceRaysIndirectKHR: indirectDeviceAddress must be a multiple of 4."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5755 | } |
| 5756 | return skip; |
| 5757 | } |
| 5758 | bool StatelessValidation::manual_PreCallValidateCmdTraceRaysNV( |
| 5759 | VkCommandBuffer commandBuffer, VkBuffer raygenShaderBindingTableBuffer, VkDeviceSize raygenShaderBindingOffset, |
| 5760 | VkBuffer missShaderBindingTableBuffer, VkDeviceSize missShaderBindingOffset, VkDeviceSize missShaderBindingStride, |
| 5761 | VkBuffer hitShaderBindingTableBuffer, VkDeviceSize hitShaderBindingOffset, VkDeviceSize hitShaderBindingStride, |
| 5762 | VkBuffer callableShaderBindingTableBuffer, VkDeviceSize callableShaderBindingOffset, VkDeviceSize callableShaderBindingStride, |
| 5763 | uint32_t width, uint32_t height, uint32_t depth) const { |
| 5764 | bool skip = false; |
| 5765 | if (SafeModulo(callableShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5766 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingOffset-02462", |
| 5767 | "vkCmdTraceRaysNV: callableShaderBindingOffset must be a multiple of " |
| 5768 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5769 | } |
| 5770 | if (SafeModulo(callableShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5771 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02465", |
| 5772 | "vkCmdTraceRaysNV: callableShaderBindingStride must be a multiple of " |
| 5773 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5774 | } |
| 5775 | if (callableShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5776 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-callableShaderBindingStride-02468", |
| 5777 | "vkCmdTraceRaysNV: callableShaderBindingStride must be less than or equal to " |
| 5778 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride. "); |
| 5779 | } |
| 5780 | |
| 5781 | // hitShader |
| 5782 | if (SafeModulo(hitShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5783 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingOffset-02460", |
| 5784 | "vkCmdTraceRaysNV: hitShaderBindingOffset must be a multiple of " |
| 5785 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5786 | } |
| 5787 | if (SafeModulo(hitShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5788 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02464", |
| 5789 | "vkCmdTraceRaysNV: hitShaderBindingStride must be a multiple of " |
| 5790 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5791 | } |
| 5792 | if (hitShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5793 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-hitShaderBindingStride-02467", |
| 5794 | "vkCmdTraceRaysNV: hitShaderBindingStride must be less than or equal to " |
| 5795 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 5796 | } |
| 5797 | |
| 5798 | // missShader |
| 5799 | if (SafeModulo(missShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5800 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingOffset-02458", |
| 5801 | "vkCmdTraceRaysNV: missShaderBindingOffset must be a multiple of " |
| 5802 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5803 | } |
| 5804 | if (SafeModulo(missShaderBindingStride, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupHandleSize) != 0) { |
| 5805 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02463", |
| 5806 | "vkCmdTraceRaysNV: missShaderBindingStride must be a multiple of " |
| 5807 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupHandleSize."); |
| 5808 | } |
| 5809 | if (missShaderBindingStride > phys_dev_ext_props.ray_tracing_propsNV.maxShaderGroupStride) { |
| 5810 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-missShaderBindingStride-02466", |
| 5811 | "vkCmdTraceRaysNV: missShaderBindingStride must be less than or equal to " |
| 5812 | "VkPhysicalDeviceRayTracingPropertiesNV::maxShaderGroupStride."); |
| 5813 | } |
| 5814 | |
| 5815 | // raygenShader |
| 5816 | if (SafeModulo(raygenShaderBindingOffset, phys_dev_ext_props.ray_tracing_propsNV.shaderGroupBaseAlignment) != 0) { |
| 5817 | skip |= LogError(device, "VUID-vkCmdTraceRaysNV-raygenShaderBindingOffset-02456", |
| 5818 | "vkCmdTraceRaysNV: raygenShaderBindingOffset must be a multiple of " |
sourav parmar | d152180 | 2020-06-07 21:49:02 -0700 | [diff] [blame] | 5819 | "VkPhysicalDeviceRayTracingPropertiesNV::shaderGroupBaseAlignment."); |
| 5820 | } |
| 5821 | if (width > device_limits.maxComputeWorkGroupCount[0]) { |
| 5822 | skip |= |
| 5823 | LogError(device, "VUID-vkCmdTraceRaysNV-width-02469", |
| 5824 | "vkCmdTraceRaysNV: width must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[o]."); |
| 5825 | } |
| 5826 | if (height > device_limits.maxComputeWorkGroupCount[1]) { |
| 5827 | skip |= |
| 5828 | LogError(device, "VUID-vkCmdTraceRaysNV-height-02470", |
| 5829 | "vkCmdTraceRaysNV: height must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[1]."); |
| 5830 | } |
| 5831 | if (depth > device_limits.maxComputeWorkGroupCount[2]) { |
| 5832 | skip |= |
| 5833 | LogError(device, "VUID-vkCmdTraceRaysNV-depth-02471", |
| 5834 | "vkCmdTraceRaysNV: depth must be less than or equal to VkPhysicalDeviceLimits::maxComputeWorkGroupCount[2]."); |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5835 | } |
| 5836 | return skip; |
| 5837 | } |
| 5838 | |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5839 | bool StatelessValidation::manual_PreCallValidateGetDeviceAccelerationStructureCompatibilityKHR( |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5840 | VkDevice device, const VkAccelerationStructureVersionInfoKHR *pVersionInfo, |
| 5841 | VkAccelerationStructureCompatibilityKHR *pCompatibility) const { |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5842 | bool skip = false; |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5843 | const auto *ray_query_features = lvl_find_in_chain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5844 | const auto *raytracing_features = lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
Nathaniel Cesario | ce9b481 | 2020-12-17 08:55:28 -0700 | [diff] [blame] | 5845 | if ((!raytracing_features && !ray_query_features) || ((ray_query_features && !(ray_query_features->rayQuery)) || |
| 5846 | (raytracing_features && !raytracing_features->rayTracingPipeline))) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5847 | skip |= LogError(device, "VUID-vkGetDeviceAccelerationStructureCompatibilityKHR-rayTracingPipeline-03661", |
sourav parmar | 83c31b1 | 2020-05-06 12:30:54 -0700 | [diff] [blame] | 5848 | "vkGetDeviceAccelerationStructureCompatibilityKHR: The rayTracing or rayQuery feature must be enabled."); |
| 5849 | } |
| 5850 | return skip; |
| 5851 | } |
| 5852 | |
Piers Daniell | 39842ee | 2020-07-10 16:42:33 -0600 | [diff] [blame] | 5853 | bool StatelessValidation::manual_PreCallValidateCmdSetViewportWithCountEXT(VkCommandBuffer commandBuffer, uint32_t viewportCount, |
| 5854 | const VkViewport *pViewports) const { |
| 5855 | bool skip = false; |
| 5856 | |
| 5857 | if (!physical_device_features.multiViewport) { |
| 5858 | if (viewportCount != 1) { |
| 5859 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03395", |
| 5860 | "vkCmdSetViewportWithCountEXT: The multiViewport feature is disabled, but viewportCount (=%" PRIu32 |
| 5861 | ") is not 1.", |
| 5862 | viewportCount); |
| 5863 | } |
| 5864 | } else { // multiViewport enabled |
| 5865 | if (viewportCount < 1 || viewportCount > device_limits.maxViewports) { |
| 5866 | skip |= LogError(commandBuffer, "VUID-vkCmdSetViewportWithCountEXT-viewportCount-03394", |
| 5867 | "vkCmdSetViewportWithCountEXT: viewportCount (=%" PRIu32 |
| 5868 | ") must " |
| 5869 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5870 | viewportCount, device_limits.maxViewports); |
| 5871 | } |
| 5872 | } |
| 5873 | |
| 5874 | if (pViewports) { |
| 5875 | for (uint32_t viewport_i = 0; viewport_i < viewportCount; ++viewport_i) { |
| 5876 | const auto &viewport = pViewports[viewport_i]; // will crash on invalid ptr |
| 5877 | const char *fn_name = "vkCmdSetViewportWithCountEXT"; |
| 5878 | skip |= manual_PreCallValidateViewport( |
| 5879 | viewport, fn_name, ParameterName("pViewports[%i]", ParameterName::IndexVector{viewport_i}), commandBuffer); |
| 5880 | } |
| 5881 | } |
| 5882 | |
| 5883 | return skip; |
| 5884 | } |
| 5885 | |
| 5886 | bool StatelessValidation::manual_PreCallValidateCmdSetScissorWithCountEXT(VkCommandBuffer commandBuffer, uint32_t scissorCount, |
| 5887 | const VkRect2D *pScissors) const { |
| 5888 | bool skip = false; |
| 5889 | |
| 5890 | if (!physical_device_features.multiViewport) { |
| 5891 | if (scissorCount != 1) { |
| 5892 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03398", |
| 5893 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 5894 | ") must " |
| 5895 | "be 1 when the multiViewport feature is disabled.", |
| 5896 | scissorCount); |
| 5897 | } |
| 5898 | } else { // multiViewport enabled |
| 5899 | if (scissorCount == 0) { |
| 5900 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397", |
| 5901 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 5902 | ") must " |
| 5903 | "be great than zero.", |
| 5904 | scissorCount); |
| 5905 | } else if (scissorCount > device_limits.maxViewports) { |
| 5906 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-scissorCount-03397", |
| 5907 | "vkCmdSetScissorWithCountEXT: scissorCount (=%" PRIu32 |
| 5908 | ") must " |
| 5909 | "not be greater than VkPhysicalDeviceLimits::maxViewports (=%" PRIu32 ").", |
| 5910 | scissorCount, device_limits.maxViewports); |
| 5911 | } |
| 5912 | } |
| 5913 | |
| 5914 | if (pScissors) { |
| 5915 | for (uint32_t scissor_i = 0; scissor_i < scissorCount; ++scissor_i) { |
| 5916 | const auto &scissor = pScissors[scissor_i]; // will crash on invalid ptr |
| 5917 | |
| 5918 | if (scissor.offset.x < 0) { |
| 5919 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399", |
| 5920 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.x (=%" PRIi32 ") is negative.", scissor_i, |
| 5921 | scissor.offset.x); |
| 5922 | } |
| 5923 | |
| 5924 | if (scissor.offset.y < 0) { |
| 5925 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-x-03399", |
| 5926 | "vkCmdSetScissor: pScissors[%" PRIu32 "].offset.y (=%" PRIi32 ") is negative.", scissor_i, |
| 5927 | scissor.offset.y); |
| 5928 | } |
| 5929 | |
| 5930 | const int64_t x_sum = static_cast<int64_t>(scissor.offset.x) + static_cast<int64_t>(scissor.extent.width); |
| 5931 | if (x_sum > INT32_MAX) { |
| 5932 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03400", |
| 5933 | "vkCmdSetScissor: offset.x + extent.width (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5934 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5935 | scissor.offset.x, scissor.extent.width, x_sum, scissor_i); |
| 5936 | } |
| 5937 | |
| 5938 | const int64_t y_sum = static_cast<int64_t>(scissor.offset.y) + static_cast<int64_t>(scissor.extent.height); |
| 5939 | if (y_sum > INT32_MAX) { |
| 5940 | skip |= LogError(commandBuffer, "VUID-vkCmdSetScissorWithCountEXT-offset-03401", |
| 5941 | "vkCmdSetScissor: offset.y + extent.height (=%" PRIi32 " + %" PRIu32 " = %" PRIi64 |
| 5942 | ") of pScissors[%" PRIu32 "] will overflow int32_t.", |
| 5943 | scissor.offset.y, scissor.extent.height, y_sum, scissor_i); |
| 5944 | } |
| 5945 | } |
| 5946 | } |
| 5947 | |
| 5948 | return skip; |
| 5949 | } |
| 5950 | |
| 5951 | bool StatelessValidation::manual_PreCallValidateCmdBindVertexBuffers2EXT(VkCommandBuffer commandBuffer, uint32_t firstBinding, |
| 5952 | uint32_t bindingCount, const VkBuffer *pBuffers, |
| 5953 | const VkDeviceSize *pOffsets, const VkDeviceSize *pSizes, |
| 5954 | const VkDeviceSize *pStrides) const { |
| 5955 | bool skip = false; |
| 5956 | if (firstBinding >= device_limits.maxVertexInputBindings) { |
| 5957 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03355", |
| 5958 | "vkCmdBindVertexBuffers2EXT() firstBinding (%u) must be less than maxVertexInputBindings (%u)", |
| 5959 | firstBinding, device_limits.maxVertexInputBindings); |
| 5960 | } else if ((firstBinding + bindingCount) > device_limits.maxVertexInputBindings) { |
| 5961 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-firstBinding-03356", |
| 5962 | "vkCmdBindVertexBuffers2EXT() sum of firstBinding (%u) and bindingCount (%u) must be less than " |
| 5963 | "maxVertexInputBindings (%u)", |
| 5964 | firstBinding, bindingCount, device_limits.maxVertexInputBindings); |
| 5965 | } |
| 5966 | |
| 5967 | for (uint32_t i = 0; i < bindingCount; ++i) { |
| 5968 | if (pBuffers[i] == VK_NULL_HANDLE) { |
| 5969 | const auto *robustness2_features = lvl_find_in_chain<VkPhysicalDeviceRobustness2FeaturesEXT>(device_createinfo_pnext); |
| 5970 | if (!(robustness2_features && robustness2_features->nullDescriptor)) { |
| 5971 | skip |= LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04111", |
| 5972 | "vkCmdBindVertexBuffers2EXT() required parameter pBuffers[%d] specified as VK_NULL_HANDLE", i); |
| 5973 | } else { |
| 5974 | if (pOffsets[i] != 0) { |
| 5975 | skip |= |
| 5976 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pBuffers-04112", |
| 5977 | "vkCmdBindVertexBuffers2EXT() pBuffers[%d] is VK_NULL_HANDLE, but pOffsets[%d] is not 0", i, i); |
| 5978 | } |
| 5979 | } |
| 5980 | } |
| 5981 | if (pStrides) { |
| 5982 | if (pStrides[i] > device_limits.maxVertexInputBindingStride) { |
| 5983 | skip |= |
| 5984 | LogError(commandBuffer, "VUID-vkCmdBindVertexBuffers2EXT-pStrides-03362", |
| 5985 | "vkCmdBindVertexBuffers2EXT() pStrides[%d] (%u) must be less than maxVertexInputBindingStride (%u)", i, |
| 5986 | pStrides[i], device_limits.maxVertexInputBindingStride); |
| 5987 | } |
| 5988 | } |
| 5989 | } |
| 5990 | |
| 5991 | return skip; |
| 5992 | } |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 5993 | |
| 5994 | bool StatelessValidation::ValidateAccelerationStructureBuildGeometryInfoKHR( |
| 5995 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, uint32_t infoCount, const char *api_name) const { |
| 5996 | bool skip = false; |
| 5997 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 5998 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR) { |
| 5999 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03654", |
| 6000 | "(%s): type must not be VK_ACCELERATION_STRUCTURE_TYPE_GENERIC_KHR.", api_name); |
| 6001 | } |
| 6002 | if (pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR && |
| 6003 | pInfos[i].flags & VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR) { |
| 6004 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-flags-03796", |
| 6005 | "(%s): If flags has the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_TRACE_BIT_KHR bit set," |
| 6006 | "then it must not have the VK_BUILD_ACCELERATION_STRUCTURE_PREFER_FAST_BUILD_BIT_KHR bit set.", |
| 6007 | api_name); |
| 6008 | } |
| 6009 | if (pInfos[i].pGeometries && pInfos[i].ppGeometries) { |
| 6010 | skip |= |
| 6011 | LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-pGeometries-03788", |
| 6012 | "(%s): Only one of pGeometries or ppGeometries can be a valid pointer, the other must be NULL", api_name); |
| 6013 | } |
| 6014 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && pInfos[i].geometryCount != 1) { |
| 6015 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03790", |
| 6016 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, geometryCount must be 1", api_name); |
| 6017 | } |
| 6018 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR && |
| 6019 | pInfos[i].geometryCount > phys_dev_ext_props.acc_structure_props.maxGeometryCount) { |
| 6020 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03793", |
| 6021 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then geometryCount must be" |
| 6022 | " less than or equal to VkPhysicalDeviceAccelerationStructurePropertiesKHR::maxGeometryCount", |
| 6023 | api_name); |
| 6024 | } |
| 6025 | if (pInfos[i].pGeometries) { |
| 6026 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6027 | skip |= validate_ranged_enum( |
| 6028 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometryType", ParameterName::IndexVector{i, j}), |
| 6029 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].pGeometries[j].geometryType, |
| 6030 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 6031 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6032 | if (pInfos[i].pGeometries[j].geometry.triangles.maxVertex <= 0) { |
| 6033 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655", |
| 6034 | "(%s): maxVertex must be greater than 0", api_name); |
| 6035 | } |
| 6036 | skip |= validate_struct_type( |
| 6037 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles", ParameterName::IndexVector{i, j}), |
| 6038 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6039 | &(pInfos[i].pGeometries[j].geometry.triangles), |
| 6040 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 6041 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 6042 | skip |= validate_struct_pnext( |
| 6043 | api_name, |
| 6044 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 6045 | NULL, pInfos[i].pGeometries[j].geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6046 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6047 | skip |= |
| 6048 | validate_ranged_enum(api_name, |
| 6049 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.vertexFormat", |
| 6050 | ParameterName::IndexVector{i, j}), |
| 6051 | "VkFormat", AllVkFormatEnums, pInfos[i].pGeometries[j].geometry.triangles.vertexFormat, |
| 6052 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 6053 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 6054 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6055 | &pInfos[i].pGeometries[j].geometry.triangles, |
| 6056 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 6057 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 6058 | skip |= validate_ranged_enum( |
| 6059 | api_name, |
| 6060 | ParameterName("pInfos[%i].pGeometries[%i].geometry.triangles.indexType", ParameterName::IndexVector{i, j}), |
| 6061 | "VkIndexType", AllVkIndexTypeEnums, pInfos[i].pGeometries[j].geometry.triangles.indexType, |
| 6062 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 6063 | |
| 6064 | if (pInfos[i].pGeometries[j].geometry.triangles.vertexStride > UINT32_MAX) { |
| 6065 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 6066 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 6067 | } |
| 6068 | if (pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 6069 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 6070 | pInfos[i].pGeometries[j].geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 6071 | skip |= |
| 6072 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 6073 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 6074 | api_name); |
| 6075 | } |
| 6076 | } |
| 6077 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6078 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 6079 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6080 | &pInfos[i].pGeometries[j].geometry.instances, |
| 6081 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 6082 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 6083 | skip |= validate_struct_type( |
| 6084 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.instances", ParameterName::IndexVector{i, j}), |
| 6085 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6086 | &(pInfos[i].pGeometries[j].geometry.instances), |
| 6087 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 6088 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 6089 | skip |= validate_struct_pnext( |
| 6090 | api_name, |
| 6091 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 6092 | NULL, pInfos[i].pGeometries[j].geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6093 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6094 | |
| 6095 | skip |= validate_bool32(api_name, |
| 6096 | ParameterName("pInfos[%i].pGeometries[%i].geometry.instances.arrayOfPointers", |
| 6097 | ParameterName::IndexVector{i, j}), |
| 6098 | pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers); |
| 6099 | } |
| 6100 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6101 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 6102 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6103 | &pInfos[i].pGeometries[j].geometry.aabbs, |
| 6104 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 6105 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 6106 | skip |= validate_struct_type( |
| 6107 | api_name, ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 6108 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6109 | &(pInfos[i].pGeometries[j].geometry.aabbs), |
| 6110 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 6111 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 6112 | skip |= validate_struct_pnext( |
| 6113 | api_name, |
| 6114 | ParameterName("pInfos[%i].pGeometries[%i].geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 6115 | pInfos[i].pGeometries[j].geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6116 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 6117 | if (pInfos[i].pGeometries[j].geometry.aabbs.stride > UINT32_MAX) { |
| 6118 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 6119 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 6120 | } |
| 6121 | } |
| 6122 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 6123 | pInfos[i].pGeometries[j].geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6124 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 6125 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 6126 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6127 | api_name); |
| 6128 | } |
| 6129 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 6130 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6131 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 6132 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 6133 | "of elements of" |
| 6134 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6135 | api_name); |
| 6136 | } |
| 6137 | if (pInfos[i].pGeometries[j].geometryType != pInfos[i].pGeometries[0].geometryType) { |
| 6138 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 6139 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 6140 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 6141 | api_name); |
| 6142 | } |
| 6143 | } |
| 6144 | } |
| 6145 | } |
| 6146 | if (pInfos[i].ppGeometries != NULL) { |
| 6147 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6148 | skip |= validate_ranged_enum( |
| 6149 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometryType", ParameterName::IndexVector{i, j}), |
| 6150 | "VkGeometryTypeKHR", AllVkGeometryTypeKHREnums, pInfos[i].ppGeometries[j]->geometryType, |
| 6151 | "VUID-VkAccelerationStructureGeometryKHR-geometryType-parameter"); |
| 6152 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6153 | if (pInfos[i].ppGeometries[j]->geometry.triangles.maxVertex <= 0) { |
| 6154 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-maxVertex-03655", |
| 6155 | "(%s): maxVertex must be greater than 0", api_name); |
| 6156 | } |
| 6157 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.triangles", |
| 6158 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6159 | &pInfos[i].ppGeometries[j]->geometry.triangles, |
| 6160 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, true, |
| 6161 | "VUID-VkAccelerationStructureGeometryKHR-triangles-parameter", kVUIDUndefined); |
| 6162 | skip |= validate_struct_type( |
| 6163 | api_name, |
| 6164 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles", ParameterName::IndexVector{i, j}), |
| 6165 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR", |
| 6166 | &(pInfos[i].ppGeometries[j]->geometry.triangles), |
| 6167 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_TRIANGLES_DATA_KHR, false, kVUIDUndefined, |
| 6168 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-sType-sType"); |
| 6169 | skip |= validate_struct_pnext( |
| 6170 | api_name, |
| 6171 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.pNext", ParameterName::IndexVector{i, j}), |
| 6172 | NULL, pInfos[i].ppGeometries[j]->geometry.triangles.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6173 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6174 | skip |= validate_ranged_enum(api_name, |
| 6175 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.vertexFormat", |
| 6176 | ParameterName::IndexVector{i, j}), |
| 6177 | "VkFormat", AllVkFormatEnums, |
| 6178 | pInfos[i].ppGeometries[j]->geometry.triangles.vertexFormat, |
| 6179 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexFormat-parameter"); |
| 6180 | skip |= validate_ranged_enum(api_name, |
| 6181 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.triangles.indexType", |
| 6182 | ParameterName::IndexVector{i, j}), |
| 6183 | "VkIndexType", AllVkIndexTypeEnums, |
| 6184 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType, |
| 6185 | "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-parameter"); |
| 6186 | if (pInfos[i].ppGeometries[j]->geometry.triangles.vertexStride > UINT32_MAX) { |
| 6187 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-vertexStride-03819", |
| 6188 | "(%s):vertexStride must be less than or equal to 2^32-1", api_name); |
| 6189 | } |
| 6190 | if (pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT16 && |
| 6191 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_UINT32 && |
| 6192 | pInfos[i].ppGeometries[j]->geometry.triangles.indexType != VK_INDEX_TYPE_NONE_KHR) { |
| 6193 | skip |= |
| 6194 | LogError(device, "VUID-VkAccelerationStructureGeometryTrianglesDataKHR-indexType-03798", |
| 6195 | "(%s):indexType must be VK_INDEX_TYPE_UINT16, VK_INDEX_TYPE_UINT32, or VK_INDEX_TYPE_NONE_KHR", |
| 6196 | api_name); |
| 6197 | } |
| 6198 | } |
| 6199 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6200 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.instances", |
| 6201 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6202 | &pInfos[i].ppGeometries[j]->geometry.instances, |
| 6203 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, true, |
| 6204 | "VUID-VkAccelerationStructureGeometryKHR-instances-parameter", kVUIDUndefined); |
| 6205 | skip |= validate_struct_type( |
| 6206 | api_name, |
| 6207 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances", ParameterName::IndexVector{i, j}), |
| 6208 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR", |
| 6209 | &(pInfos[i].ppGeometries[j]->geometry.instances), |
| 6210 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_INSTANCES_DATA_KHR, false, kVUIDUndefined, |
| 6211 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-sType-sType"); |
| 6212 | skip |= validate_struct_pnext( |
| 6213 | api_name, |
| 6214 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.pNext", ParameterName::IndexVector{i, j}), |
| 6215 | NULL, pInfos[i].ppGeometries[j]->geometry.instances.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6216 | "VUID-VkAccelerationStructureGeometryInstancesDataKHR-pNext-pNext", kVUIDUndefined); |
| 6217 | skip |= validate_bool32(api_name, |
| 6218 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.instances.arrayOfPointers", |
| 6219 | ParameterName::IndexVector{i, j}), |
| 6220 | pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers); |
| 6221 | } |
| 6222 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6223 | skip |= validate_struct_type(api_name, "pInfos[i].pGeometries[j].geometry.aabbs", |
| 6224 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6225 | &pInfos[i].ppGeometries[j]->geometry.aabbs, |
| 6226 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, true, |
| 6227 | "VUID-VkAccelerationStructureGeometryKHR-aabbs-parameter", kVUIDUndefined); |
| 6228 | skip |= validate_struct_type( |
| 6229 | api_name, ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs", ParameterName::IndexVector{i, j}), |
| 6230 | "VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR", |
| 6231 | &(pInfos[i].ppGeometries[j]->geometry.aabbs), |
| 6232 | VK_STRUCTURE_TYPE_ACCELERATION_STRUCTURE_GEOMETRY_AABBS_DATA_KHR, false, kVUIDUndefined, |
| 6233 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-sType-sType"); |
| 6234 | skip |= validate_struct_pnext( |
| 6235 | api_name, |
| 6236 | ParameterName("pInfos[%i].ppGeometries[%i]->geometry.aabbs.pNext", ParameterName::IndexVector{i, j}), NULL, |
| 6237 | pInfos[i].ppGeometries[j]->geometry.aabbs.pNext, 0, NULL, GeneratedVulkanHeaderVersion, |
| 6238 | "VUID-VkAccelerationStructureGeometryAabbsDataKHR-pNext-pNext", kVUIDUndefined); |
| 6239 | if (pInfos[i].ppGeometries[j]->geometry.aabbs.stride > UINT32_MAX) { |
| 6240 | skip |= LogError(device, "VUID-VkAccelerationStructureGeometryAabbsDataKHR-stride-03820", |
| 6241 | "(%s):stride must be less than or equal to 2^32-1", api_name); |
| 6242 | } |
| 6243 | } |
| 6244 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR && |
| 6245 | pInfos[i].ppGeometries[j]->geometryType != VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6246 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03789", |
| 6247 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_TOP_LEVEL_KHR, the geometryType member" |
| 6248 | " of elements of either pGeometries or ppGeometries must be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6249 | api_name); |
| 6250 | } |
| 6251 | if (pInfos[i].type == VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR) { |
| 6252 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6253 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03791", |
| 6254 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR the geometryType member " |
| 6255 | "of elements of" |
| 6256 | " either pGeometries or ppGeometries must not be VK_GEOMETRY_TYPE_INSTANCES_KHR", |
| 6257 | api_name); |
| 6258 | } |
| 6259 | if (pInfos[i].ppGeometries[j]->geometryType != pInfos[i].ppGeometries[0]->geometryType) { |
| 6260 | skip |= LogError(device, "VUID-VkAccelerationStructureBuildGeometryInfoKHR-type-03792", |
| 6261 | "(%s): If type is VK_ACCELERATION_STRUCTURE_TYPE_BOTTOM_LEVEL_KHR then the geometryType" |
| 6262 | " member of each geometry in either pGeometries or ppGeometries must be the same.", |
| 6263 | api_name); |
| 6264 | } |
| 6265 | } |
| 6266 | } |
| 6267 | } |
| 6268 | } |
| 6269 | return skip; |
| 6270 | } |
| 6271 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresKHR( |
| 6272 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 6273 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 6274 | bool skip = false; |
| 6275 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresKHR"); |
| 6276 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 6277 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 6278 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 6279 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03710", |
| 6280 | "vkCmdBuildAccelerationStructuresKHR:For each element of pInfos, its " |
| 6281 | "scratchData.deviceAddress member must be a multiple of " |
| 6282 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 6283 | } |
| 6284 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 6285 | if (i == k) continue; |
| 6286 | bool found = false; |
| 6287 | if (pInfos[i].dstAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
| 6288 | skip |= LogError( |
| 6289 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 6290 | "vkCmdBuildAccelerationStructuresKHR:The dstAccelerationStructure member of any element (%d) of pInfos must " |
| 6291 | "not be " |
| 6292 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 6293 | i, k); |
| 6294 | found = true; |
| 6295 | } |
| 6296 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
| 6297 | skip |= LogError( |
| 6298 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03403", |
| 6299 | "vkCmdBuildAccelerationStructuresKHR:The srcAccelerationStructure member of any element (%d) of pInfos must " |
| 6300 | "not be " |
| 6301 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 6302 | i, k); |
| 6303 | found = true; |
| 6304 | } |
| 6305 | if (found) break; |
| 6306 | } |
| 6307 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6308 | if (pInfos[i].pGeometries) { |
| 6309 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6310 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 6311 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 6312 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 6313 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6314 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 6315 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6316 | } |
| 6317 | } else { |
| 6318 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 6319 | skip |= |
| 6320 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 6321 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6322 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 6323 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 6324 | } |
| 6325 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 6326 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6327 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 6328 | skip |= LogError( |
| 6329 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 6330 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6331 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6332 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 6333 | } else if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6334 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6335 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 6336 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 6337 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 6338 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 6339 | } |
| 6340 | } |
| 6341 | } else if (pInfos[i].ppGeometries) { |
| 6342 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6343 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 6344 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 6345 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03716", |
| 6346 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6347 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 6348 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6349 | } |
| 6350 | } else { |
| 6351 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 6352 | skip |= |
| 6353 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03715", |
| 6354 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6355 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 6356 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 6357 | } |
| 6358 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 6359 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6360 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 6361 | skip |= LogError( |
| 6362 | device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03714", |
| 6363 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries with a " |
| 6364 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6365 | } |
Ricardo Garcia | 2ba3da8 | 2020-12-02 11:27:53 +0100 | [diff] [blame] | 6366 | } else if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6367 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.transformData.deviceAddress, 16) != 0) { |
sourav parmar | cd5fb18 | 2020-07-17 12:58:44 -0700 | [diff] [blame] | 6368 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresKHR-pInfos-03810", |
| 6369 | "vkCmdBuildAccelerationStructuresKHR:For any element of pInfos[i].pGeometries " |
| 6370 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 6371 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 6372 | } |
| 6373 | } |
| 6374 | } |
| 6375 | } |
| 6376 | } |
| 6377 | return skip; |
| 6378 | } |
| 6379 | |
| 6380 | bool StatelessValidation::manual_PreCallValidateCmdBuildAccelerationStructuresIndirectKHR( |
| 6381 | VkCommandBuffer commandBuffer, uint32_t infoCount, const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 6382 | const VkDeviceAddress *pIndirectDeviceAddresses, const uint32_t *pIndirectStrides, |
| 6383 | const uint32_t *const *ppMaxPrimitiveCounts) const { |
| 6384 | bool skip = false; |
| 6385 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkCmdBuildAccelerationStructuresIndirectKHR"); |
| 6386 | const auto *ray_tracing_acceleration_structure_features = |
| 6387 | lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
| 6388 | if (!ray_tracing_acceleration_structure_features || |
| 6389 | ray_tracing_acceleration_structure_features->accelerationStructureIndirectBuild == VK_FALSE) { |
| 6390 | skip |= LogError( |
| 6391 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-accelerationStructureIndirectBuild-03650", |
| 6392 | "vkCmdBuildAccelerationStructuresIndirectKHR: The " |
| 6393 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureIndirectBuild feature must be enabled."); |
| 6394 | } |
| 6395 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 6396 | if (pInfos[i].mode == VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR) { |
| 6397 | if (pInfos[i].srcAccelerationStructure == VK_NULL_HANDLE) { |
| 6398 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03666", |
| 6399 | "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, if its mode member is " |
| 6400 | "VK_BUILD_ACCELERATION_STRUCTURE_MODE_UPDATE_KHR, its srcAccelerationStructure member must not be " |
| 6401 | "VK_NULL_HANDLE."); |
| 6402 | } |
| 6403 | } |
| 6404 | if (SafeModulo(pInfos[i].scratchData.deviceAddress, |
| 6405 | phys_dev_ext_props.acc_structure_props.minAccelerationStructureScratchOffsetAlignment) != 0) { |
| 6406 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03710", |
| 6407 | "vkCmdBuildAccelerationStructuresIndirectKHR:For each element of pInfos, its " |
| 6408 | "scratchData.deviceAddress member must be a multiple of " |
| 6409 | "VkPhysicalDeviceAccelerationStructurePropertiesKHR::minAccelerationStructureScratchOffsetAlignment."); |
| 6410 | } |
| 6411 | for (uint32_t k = 0; k < infoCount; ++k) { |
| 6412 | if (i == k) continue; |
| 6413 | if (pInfos[i].srcAccelerationStructure == pInfos[k].dstAccelerationStructure) { |
| 6414 | skip |= |
| 6415 | LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03403", |
| 6416 | "vkCmdBuildAccelerationStructuresIndirectKHR:The srcAccelerationStructure member of any element (%d) " |
| 6417 | "of pInfos must not be the same acceleration structure as the dstAccelerationStructure member of " |
| 6418 | "any other element [%d) of pInfos.", |
| 6419 | i, k); |
| 6420 | break; |
| 6421 | } |
| 6422 | } |
| 6423 | for (uint32_t j = 0; j < pInfos[i].geometryCount; ++j) { |
| 6424 | if (pInfos[i].pGeometries) { |
| 6425 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6426 | if (pInfos[i].pGeometries[j].geometry.instances.arrayOfPointers == VK_TRUE) { |
| 6427 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 6428 | skip |= LogError( |
| 6429 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 6430 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6431 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 6432 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6433 | } |
| 6434 | } else { |
| 6435 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 16) != 0) { |
| 6436 | skip |= LogError( |
| 6437 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 6438 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6439 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 6440 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 6441 | } |
| 6442 | } |
| 6443 | } |
| 6444 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6445 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.instances.data.deviceAddress, 8) != 0) { |
| 6446 | skip |= LogError( |
| 6447 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 6448 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6449 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6450 | } |
| 6451 | } |
| 6452 | if (pInfos[i].pGeometries[j].geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6453 | if (SafeModulo(pInfos[i].pGeometries[j].geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 6454 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 6455 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 6456 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 6457 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 6458 | } |
| 6459 | } |
| 6460 | } else if (pInfos[i].ppGeometries) { |
| 6461 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_INSTANCES_KHR) { |
| 6462 | if (pInfos[i].ppGeometries[j]->geometry.instances.arrayOfPointers == VK_TRUE) { |
| 6463 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 6464 | skip |= LogError( |
| 6465 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03716", |
| 6466 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6467 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is " |
| 6468 | "VK_TRUE, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6469 | } |
| 6470 | } else { |
| 6471 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 16) != 0) { |
| 6472 | skip |= LogError( |
| 6473 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03715", |
| 6474 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6475 | "geometryType of VK_GEOMETRY_TYPE_INSTANCES_KHR, if geometry.arrayOfPointers is VK_FALSE, " |
| 6476 | "geometry.data->deviceAddress must be aligned to 16 bytes."); |
| 6477 | } |
| 6478 | } |
| 6479 | } |
| 6480 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_AABBS_KHR) { |
| 6481 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.instances.data.deviceAddress, 8) != 0) { |
| 6482 | skip |= LogError( |
| 6483 | device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03714", |
| 6484 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries with a " |
| 6485 | "geometryType of VK_GEOMETRY_TYPE_AABBS_KHR, geometry.data->deviceAddress must be aligned to 8 bytes."); |
| 6486 | } |
| 6487 | } |
| 6488 | if (pInfos[i].ppGeometries[j]->geometryType == VK_GEOMETRY_TYPE_TRIANGLES_KHR) { |
| 6489 | if (SafeModulo(pInfos[i].ppGeometries[j]->geometry.triangles.indexData.deviceAddress, 16) != 0) { |
| 6490 | skip |= LogError(device, "VUID-vkCmdBuildAccelerationStructuresIndirectKHR-pInfos-03810", |
| 6491 | "vkCmdBuildAccelerationStructuresIndirectKHR:For any element of pInfos[i].pGeometries " |
| 6492 | "with a geometryType of VK_GEOMETRY_TYPE_TRIANGLES_KHR, " |
| 6493 | "geometry.transformData->deviceAddress must be aligned to 16 bytes."); |
| 6494 | } |
| 6495 | } |
| 6496 | } |
| 6497 | } |
| 6498 | } |
| 6499 | return skip; |
| 6500 | } |
| 6501 | |
| 6502 | bool StatelessValidation::manual_PreCallValidateBuildAccelerationStructuresKHR( |
| 6503 | VkDevice device, VkDeferredOperationKHR deferredOperation, uint32_t infoCount, |
| 6504 | const VkAccelerationStructureBuildGeometryInfoKHR *pInfos, |
| 6505 | const VkAccelerationStructureBuildRangeInfoKHR *const *ppBuildRangeInfos) const { |
| 6506 | bool skip = false; |
| 6507 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pInfos, infoCount, "vkBuildAccelerationStructuresKHR"); |
| 6508 | const auto *ray_tracing_acceleration_structure_features = |
| 6509 | lvl_find_in_chain<VkPhysicalDeviceAccelerationStructureFeaturesKHR>(device_createinfo_pnext); |
| 6510 | if (!ray_tracing_acceleration_structure_features || |
| 6511 | ray_tracing_acceleration_structure_features->accelerationStructureHostCommands == VK_FALSE) { |
| 6512 | skip |= |
| 6513 | LogError(device, "VUID-vkBuildAccelerationStructuresKHR-accelerationStructureHostCommands-03581", |
| 6514 | "vkBuildAccelerationStructuresKHR: The " |
| 6515 | "VkPhysicalDeviceAccelerationStructureFeaturesKHR::accelerationStructureHostCommands feature must be enabled"); |
| 6516 | } |
| 6517 | for (uint32_t i = 0; i < infoCount; ++i) { |
| 6518 | for (uint32_t j = 0; j < infoCount; ++j) { |
| 6519 | if (i == j) continue; |
| 6520 | bool found = false; |
| 6521 | if (pInfos[i].dstAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
| 6522 | skip |= LogError( |
| 6523 | device, "VUID-vkBuildAccelerationStructuresKHR-dstAccelerationStructure-03698", |
| 6524 | "vkBuildAccelerationStructuresKHR(): The dstAccelerationStructure member of any element (%d) of pInfos must " |
| 6525 | "not be " |
| 6526 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 6527 | i, j); |
| 6528 | found = true; |
| 6529 | } |
| 6530 | if (pInfos[i].srcAccelerationStructure == pInfos[j].dstAccelerationStructure) { |
| 6531 | skip |= LogError( |
| 6532 | device, "VUID-vkBuildAccelerationStructuresKHR-pInfos-03403", |
| 6533 | "vkBuildAccelerationStructuresKHR(): The srcAccelerationStructure member of any element (%d) of pInfos must " |
| 6534 | "not be " |
| 6535 | "the same acceleration structure as the dstAccelerationStructure member of any other element (%d) of pInfos.", |
| 6536 | i, j); |
| 6537 | found = true; |
| 6538 | } |
| 6539 | if (found) break; |
| 6540 | } |
| 6541 | } |
| 6542 | return skip; |
| 6543 | } |
| 6544 | |
| 6545 | bool StatelessValidation::manual_PreCallValidateGetAccelerationStructureBuildSizesKHR( |
| 6546 | VkDevice device, VkAccelerationStructureBuildTypeKHR buildType, const VkAccelerationStructureBuildGeometryInfoKHR *pBuildInfo, |
| 6547 | const uint32_t *pMaxPrimitiveCounts, VkAccelerationStructureBuildSizesInfoKHR *pSizeInfo) const { |
| 6548 | bool skip = false; |
| 6549 | skip |= ValidateAccelerationStructureBuildGeometryInfoKHR(pBuildInfo, 1, "vkGetAccelerationStructureBuildSizesKHR"); |
| 6550 | const auto *ray_tracing_pipeline_features = |
| 6551 | lvl_find_in_chain<VkPhysicalDeviceRayTracingPipelineFeaturesKHR>(device_createinfo_pnext); |
| 6552 | const auto *ray_query_features = lvl_find_in_chain<VkPhysicalDeviceRayQueryFeaturesKHR>(device_createinfo_pnext); |
| 6553 | if (!(ray_tracing_pipeline_features || ray_query_features) || |
| 6554 | ((ray_tracing_pipeline_features && ray_tracing_pipeline_features->rayTracingPipeline == VK_FALSE) || |
| 6555 | (ray_query_features && ray_query_features->rayQuery == VK_FALSE))) { |
| 6556 | skip |= LogError(device, "VUID-vkGetAccelerationStructureBuildSizesKHR-rayTracingPipeline-03617", |
| 6557 | "vkGetAccelerationStructureBuildSizesKHR:The rayTracingPipeline or rayQuery feature must be enabled"); |
| 6558 | } |
| 6559 | return skip; |
| 6560 | } |