Petr Kraus | 18b7d1f | 2020-03-31 21:12:30 +0200 | [diff] [blame^] | 1 | /* Copyright (c) 2020 The Khronos Group Inc. |
| 2 | * Copyright (c) 2020 Valve Corporation |
| 3 | * Copyright (c) 2020 LunarG, Inc. |
| 4 | * |
| 5 | * Licensed under the Apache License, Version 2.0 (the "License"); |
| 6 | * you may not use this file except in compliance with the License. |
| 7 | * You may obtain a copy of the License at |
| 8 | * |
| 9 | * http://www.apache.org/licenses/LICENSE-2.0 |
| 10 | * |
| 11 | * Unless required by applicable law or agreed to in writing, software |
| 12 | * distributed under the License is distributed on an "AS IS" BASIS, |
| 13 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 14 | * See the License for the specific language governing permissions and |
| 15 | * limitations under the License. |
| 16 | */ |
| 17 | |
| 18 | // Instanceless tests |
| 19 | // Tests of validation of vkCreateInstance and vkDestroyInstance via the pNext debug callback. |
| 20 | // |
| 21 | // This set of test should ideally be as complete as possible. Most of the VUs are Implicit (i.e. automatically generated), but any |
| 22 | // of the parameters could expose a bug or inadequacy in the Loader or the debug extension. |
| 23 | // |
| 24 | // Note: testing pCreateInfo pointer, the sType of a debug struct, the debug callback pointer, the ppEnabledLayerNames pointer, and |
| 25 | // the ppEnabledExtensionNames would require extenally enabled debug layers, so this is currently not performed. |
| 26 | // |
| 27 | // TODO: some check are disabled because they are failing |
| 28 | // TODO: some checks have problems with the loader requiring a workaround |
| 29 | // TODO: VkDebugReportCallbackCreateInfoEXT::flags and VkDebugUtilsMessengerCreateInfoEXT various Flags could theoretically be |
| 30 | // tested if the debug extensions are made robust enough |
| 31 | |
| 32 | #include <memory> |
| 33 | #include <vector> |
| 34 | |
| 35 | #include "cast_utils.h" |
| 36 | #include "layer_validation_tests.h" |
| 37 | |
| 38 | static VkInstance dummy_instance; |
| 39 | |
| 40 | TEST_F(VkLayerTest, InstanceExtensionDependencies) { |
| 41 | TEST_DESCRIPTION("Test enabling instance extension without dependencies met."); |
| 42 | |
| 43 | if (!InstanceExtensionSupported(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME)) { |
| 44 | printf("%s Did not find required instance extension %s.\n", kSkipPrefix, VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
| 45 | return; |
| 46 | } |
| 47 | ASSERT_TRUE(InstanceExtensionSupported(VK_KHR_SURFACE_EXTENSION_NAME)); // Driver should always provide dependencies |
| 48 | |
| 49 | Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-vkCreateInstance-ppEnabledExtensionNames-01388"); |
| 50 | instance_extensions_.push_back(VK_KHR_GET_SURFACE_CAPABILITIES_2_EXTENSION_NAME); |
| 51 | const auto ici = GetInstanceCreateInfo(); |
| 52 | vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 53 | Monitor().VerifyFound(); |
| 54 | |
| 55 | // WORKAROUND: Subsequent tests crash when this is not called. MockICD or Loader bug? |
| 56 | vk::DestroyInstance(dummy_instance, nullptr); |
| 57 | } |
| 58 | |
| 59 | // TODO: Defunct because of the instance bug, and we cannot workaround by destroying the instance because we pass NULL |
| 60 | // TEST_F(VkLayerTest, InstanceNullReturnPtr) { |
| 61 | // TEST_DESCRIPTION("Test creating instance with NULL pInstance."); |
| 62 | // |
| 63 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-vkCreateInstance-pInstance-parameter"); |
| 64 | // vk::CreateInstance(&GetInstanceCreateInfo(), nullptr, nullptr); |
| 65 | // Monitor().VerifyFound(); |
| 66 | //} |
| 67 | |
| 68 | void* VKAPI_PTR DummyAlloc(void*, size_t size, size_t alignment, VkSystemAllocationScope) { |
| 69 | size_t space = size + alignment - 1; |
| 70 | void* mem_ptr = std::malloc(space); |
| 71 | return std::align(alignment, size, mem_ptr, space); |
| 72 | } |
| 73 | void VKAPI_PTR DummyFree(void*, void* pMemory) { |
| 74 | // just leak it |
| 75 | } |
| 76 | void* VKAPI_PTR DummyRealloc(void* pUserData, void* pOriginal, size_t size, size_t alignment, |
| 77 | VkSystemAllocationScope allocationScope) { |
| 78 | DummyFree(pUserData, pOriginal); |
| 79 | return DummyAlloc(pUserData, size, alignment, allocationScope); |
| 80 | } |
| 81 | void VKAPI_PTR DummyInfoAlloc(void*, size_t, VkInternalAllocationType, VkSystemAllocationScope) {} |
| 82 | void VKAPI_PTR DummyInfoFree(void*, size_t, VkInternalAllocationType, VkSystemAllocationScope) {} |
| 83 | |
| 84 | // TODO: Loader hates this; if it can, it should call layers first before using allocators |
| 85 | // TEST_F(VkLayerTest, InstanceAllocationCallbacks) { |
| 86 | // TEST_DESCRIPTION("Test creating instance with invalid allocation callbacks."); |
| 87 | // |
| 88 | // const auto ici = GetInstanceCreateInfo(); |
| 89 | // const VkAllocationCallbacks alloc_callbacks = {nullptr, &DummyAlloc, &DummyRealloc, |
| 90 | // &DummyFree, &DummyInfoAlloc, &DummyInfoFree}; |
| 91 | // |
| 92 | // enum TestedFn { kCreate, kDestroy }; |
| 93 | // struct TestCase { |
| 94 | // const char* vuid; |
| 95 | // TestedFn tested_fn; |
| 96 | // VkAllocationCallbacks test_ac; |
| 97 | // }; |
| 98 | // |
| 99 | // const std::vector<TestCase> test_cases = { |
| 100 | // {"VUID-VkAllocationCallbacks-pfnAllocation-00632", |
| 101 | // kCreate, |
| 102 | // {nullptr, nullptr, &DummyRealloc, &DummyFree, &DummyInfoAlloc, &DummyInfoFree}}, |
| 103 | // {"VUID-VkAllocationCallbacks-pfnAllocation-00632", |
| 104 | // kDestroy, |
| 105 | // {nullptr, nullptr, &DummyRealloc, &DummyFree, &DummyInfoAlloc, &DummyInfoFree}}, |
| 106 | // {"VUID-VkAllocationCallbacks-pfnReallocation-00633", |
| 107 | // kCreate, |
| 108 | // {nullptr, &DummyAlloc, nullptr, &DummyFree, &DummyInfoAlloc, &DummyInfoFree}}, |
| 109 | // {"VUID-VkAllocationCallbacks-pfnReallocation-00633", |
| 110 | // kDestroy, |
| 111 | // {nullptr, &DummyAlloc, nullptr, &DummyFree, &DummyInfoAlloc, &DummyInfoFree}}, |
| 112 | // {"VUID-VkAllocationCallbacks-pfnFree-00634", |
| 113 | // kCreate, |
| 114 | // {nullptr, &DummyAlloc, &DummyRealloc, nullptr, &DummyInfoAlloc, &DummyInfoFree}}, |
| 115 | // {"VUID-VkAllocationCallbacks-pfnFree-00634", |
| 116 | // kDestroy, |
| 117 | // {nullptr, &DummyAlloc, &DummyRealloc, nullptr, &DummyInfoAlloc, &DummyInfoFree}}, |
| 118 | // {"VUID-VkAllocationCallbacks-pfnInternalAllocation-00635", |
| 119 | // kCreate, |
| 120 | // {nullptr, &DummyAlloc, &DummyRealloc, &DummyFree, nullptr, &DummyInfoFree}}, |
| 121 | // {"VUID-VkAllocationCallbacks-pfnInternalAllocation-00635", |
| 122 | // kDestroy, |
| 123 | // {nullptr, &DummyAlloc, &DummyRealloc, &DummyFree, nullptr, &DummyInfoFree}}, |
| 124 | // {"VUID-VkAllocationCallbacks-pfnInternalAllocation-006352", |
| 125 | // kCreate, |
| 126 | // {nullptr, &DummyAlloc, &DummyRealloc, &DummyFree, &DummyInfoAlloc, nullptr}}, |
| 127 | // {"VUID-VkAllocationCallbacks-pfnInternalAllocation-00635", |
| 128 | // kDestroy, |
| 129 | // {nullptr, &DummyAlloc, &DummyRealloc, &DummyFree, &DummyInfoAlloc, nullptr}}, |
| 130 | // }; |
| 131 | // |
| 132 | // for (const auto& test_case : test_cases) { |
| 133 | // if (test_case.tested_fn == kCreate) { |
| 134 | // Monitor().SetDesiredFailureMsg(kErrorBit, test_case.vuid); |
| 135 | // vk::CreateInstance(&ici, &test_case.test_ac, &dummy_instance); |
| 136 | // Monitor().VerifyFound(); |
| 137 | // |
| 138 | // //vk::DestroyInstance(dummy_instance, &alloc_callbacks); // WORKAROUND |
| 139 | // } |
| 140 | // |
| 141 | // if (test_case.tested_fn == kDestroy) { |
| 142 | // VkInstance instance; |
| 143 | // ASSERT_VK_SUCCESS(vk::CreateInstance(&ici, &alloc_callbacks, &instance)); |
| 144 | // |
| 145 | // Monitor().SetDesiredFailureMsg(kErrorBit, test_case.vuid); |
| 146 | // vk::DestroyInstance(instance, &test_case.test_ac); |
| 147 | // Monitor().VerifyFound(); |
| 148 | // |
| 149 | // // cleanup |
| 150 | // vk::DestroyInstance(instance, &alloc_callbacks); |
| 151 | // } |
| 152 | // } |
| 153 | //} |
| 154 | |
| 155 | TEST_F(VkLayerTest, InstanceBadStype) { |
| 156 | TEST_DESCRIPTION("Test creating instance with bad sType."); |
| 157 | |
| 158 | auto ici = GetInstanceCreateInfo(); |
| 159 | |
| 160 | Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkInstanceCreateInfo-sType-sType"); |
| 161 | ici.sType = VK_STRUCTURE_TYPE_APPLICATION_INFO; |
| 162 | vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 163 | Monitor().VerifyFound(); |
| 164 | |
| 165 | // WORKAROUND: Subsequent tests crash when this is not called. MockICD or Loader bug? |
| 166 | vk::DestroyInstance(dummy_instance, nullptr); |
| 167 | } |
| 168 | |
| 169 | // TODO: Fails |
| 170 | // TEST_F(VkLayerTest, InstanceBadPnextStype) { |
| 171 | // TEST_DESCRIPTION("Test creating instance with bad sType in the pNext chain."); |
| 172 | // |
| 173 | // auto ici = GetInstanceCreateInfo(); |
| 174 | // |
| 175 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkInstanceCreateInfo-pNext-pNext"); |
| 176 | // VkBaseInStructure invalid_struct = { |
| 177 | // VK_STRUCTURE_TYPE_APPLICATION_INFO, |
| 178 | // reinterpret_cast<const VkBaseInStructure* >(ici.pNext) |
| 179 | // }; |
| 180 | // ici.pNext = &invalid_struct; |
| 181 | // vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 182 | // Monitor().VerifyFound(); |
| 183 | // |
| 184 | // // WORKAROUND: Subsequent tests crash when this is not called. MockICD or Loader bug? |
| 185 | // vk::DestroyInstance(dummy_instance, nullptr); |
| 186 | //} |
| 187 | |
| 188 | TEST_F(VkLayerTest, InstanceDuplicatePnextStype) { |
| 189 | TEST_DESCRIPTION("Test creating instance with duplicate sType in the pNext chain."); |
| 190 | |
| 191 | if (!InstanceExtensionSupported(VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME)) { |
| 192 | printf("%s Did not find required instance extension %s.\n", kSkipPrefix, VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME); |
| 193 | return; |
| 194 | } |
| 195 | instance_extensions_.push_back(VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME); |
| 196 | |
| 197 | auto ici = GetInstanceCreateInfo(); |
| 198 | |
| 199 | Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkInstanceCreateInfo-sType-unique"); |
| 200 | const VkValidationFeaturesEXT duplicate_pnext = {VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT, ici.pNext}; |
| 201 | const VkValidationFeaturesEXT first_pnext = {VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT, &duplicate_pnext}; |
| 202 | ici.pNext = &first_pnext; |
| 203 | vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 204 | Monitor().VerifyFound(); |
| 205 | |
| 206 | // WORKAROUND: Subsequent tests crash when this is not called. MockICD or Loader bug? |
| 207 | vk::DestroyInstance(dummy_instance, nullptr); |
| 208 | } |
| 209 | |
| 210 | TEST_F(VkLayerTest, InstanceFlags) { |
| 211 | TEST_DESCRIPTION("Test creating instance with invalid flags."); |
| 212 | |
| 213 | auto ici = GetInstanceCreateInfo(); |
| 214 | |
| 215 | Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkInstanceCreateInfo-flags-zerobitmask"); |
| 216 | ici.flags = (VkInstanceCreateFlags)1; |
| 217 | vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 218 | Monitor().VerifyFound(); |
| 219 | |
| 220 | // WORKAROUND: Subsequent tests crash when this is not called. MockICD or Loader bug? |
| 221 | vk::DestroyInstance(dummy_instance, nullptr); |
| 222 | } |
| 223 | |
| 224 | TEST_F(VkLayerTest, InstanceAppInfoBadStype) { |
| 225 | TEST_DESCRIPTION("Test creating instance with invalid sType in VkApplicationInfo."); |
| 226 | |
| 227 | auto ici = GetInstanceCreateInfo(); |
| 228 | |
| 229 | VkApplicationInfo bad_app_info = {}; |
| 230 | if (ici.pApplicationInfo) bad_app_info = *ici.pApplicationInfo; |
| 231 | bad_app_info.sType = VK_STRUCTURE_TYPE_INSTANCE_CREATE_INFO; |
| 232 | ici.pApplicationInfo = &bad_app_info; |
| 233 | |
| 234 | Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkApplicationInfo-sType-sType"); |
| 235 | vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 236 | Monitor().VerifyFound(); |
| 237 | |
| 238 | // WORKAROUND: Subsequent tests crash when this is not called. MockICD or Loader bug? |
| 239 | vk::DestroyInstance(dummy_instance, nullptr); |
| 240 | } |
| 241 | |
| 242 | // TODO: fails |
| 243 | // TEST_F(VkLayerTest, InstanceAppInfoBadPnext) { |
| 244 | // TEST_DESCRIPTION("Test creating instance with invalid pNext in VkApplicationInfo."); |
| 245 | // |
| 246 | // auto ici = GetInstanceCreateInfo(); |
| 247 | // |
| 248 | // VkApplicationInfo bad_app_info = {}; |
| 249 | // if( ici.pApplicationInfo ) bad_app_info = *ici.pApplicationInfo; |
| 250 | // ASSERT_TRUE(!ici.pApplicationInfo || ici.pApplicationInfo->pNext == nullptr); // test framework should not be using the pNext |
| 251 | // bad_app_info.pNext = reinterpret_cast<void*>(0x1); |
| 252 | // ici.pApplicationInfo = &bad_app_info; |
| 253 | // |
| 254 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkApplicationInfo-pNext-pNext"); |
| 255 | // vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 256 | // Monitor().VerifyFound(); |
| 257 | // |
| 258 | // // WORKAROUND: Subsequent tests crash when this is not called. MockICD or Loader bug? |
| 259 | // vk::DestroyInstance(dummy_instance, nullptr); |
| 260 | //} |
| 261 | |
| 262 | TEST_F(VkLayerTest, InstanceValidationFeaturesBadFlags) { |
| 263 | TEST_DESCRIPTION("Test creating instance with invalid flags in VkValidationFeaturesEXT."); |
| 264 | |
| 265 | if (!InstanceExtensionSupported(VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME)) { |
| 266 | printf("%s Did not find required instance extension %s.\n", kSkipPrefix, VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME); |
| 267 | return; |
| 268 | } |
| 269 | instance_extensions_.push_back(VK_EXT_VALIDATION_FEATURES_EXTENSION_NAME); |
| 270 | |
| 271 | auto ici = GetInstanceCreateInfo(); |
| 272 | |
| 273 | // the test framework should not be using VkValidationFeatureEnableEXT itself |
| 274 | for (auto traversable_pnext = reinterpret_cast<const VkBaseInStructure*>(ici.pNext); traversable_pnext; |
| 275 | traversable_pnext = traversable_pnext->pNext) { |
| 276 | ASSERT_NE(traversable_pnext->sType, VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT); |
| 277 | } |
| 278 | |
| 279 | VkValidationFeaturesEXT validation_features = {}; |
| 280 | validation_features.sType = VK_STRUCTURE_TYPE_VALIDATION_FEATURES_EXT; |
| 281 | validation_features.pNext = ici.pNext; |
| 282 | ici.pNext = &validation_features; |
| 283 | |
| 284 | { |
| 285 | validation_features.enabledValidationFeatureCount = 1; |
| 286 | validation_features.pEnabledValidationFeatures = nullptr; |
| 287 | validation_features.disabledValidationFeatureCount = 0; |
| 288 | validation_features.pDisabledValidationFeatures = nullptr; |
| 289 | |
| 290 | // TODO: Crashes |
| 291 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-parameter"); |
| 292 | // vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 293 | // Monitor().VerifyFound(); |
| 294 | // vk::DestroyInstance(dummy_instance, nullptr); // WORKAROUND |
| 295 | |
| 296 | const VkValidationFeatureEnableEXT bad_enable = (VkValidationFeatureEnableEXT)0x42; |
| 297 | validation_features.pEnabledValidationFeatures = &bad_enable; |
| 298 | |
| 299 | // TODO: Does not have a proper VUID |
| 300 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-parameter"); |
| 301 | Monitor().SetDesiredFailureMsg(kErrorBit, "UNASSIGNED-GeneralParameterError-UnrecognizedValue"); |
| 302 | vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 303 | Monitor().VerifyFound(); |
| 304 | vk::DestroyInstance(dummy_instance, nullptr); // WORKAROUND |
| 305 | } |
| 306 | |
| 307 | { |
| 308 | validation_features.enabledValidationFeatureCount = 0; |
| 309 | validation_features.pEnabledValidationFeatures = nullptr; |
| 310 | validation_features.disabledValidationFeatureCount = 1; |
| 311 | validation_features.pDisabledValidationFeatures = nullptr; |
| 312 | |
| 313 | // TODO: Crashes |
| 314 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-parameter"); |
| 315 | // vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 316 | // Monitor().VerifyFound(); |
| 317 | // vk::DestroyInstance(dummy_instance, nullptr); // WORKAROUND |
| 318 | |
| 319 | const VkValidationFeatureDisableEXT bad_disable = (VkValidationFeatureDisableEXT)0x42; |
| 320 | validation_features.pDisabledValidationFeatures = &bad_disable; |
| 321 | |
| 322 | // TODO: Does not have a proper VUID |
| 323 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkValidationFeaturesEXT-pEnabledValidationFeatures-parameter"); |
| 324 | Monitor().SetDesiredFailureMsg(kErrorBit, "UNASSIGNED-GeneralParameterError-UnrecognizedValue"); |
| 325 | vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 326 | Monitor().VerifyFound(); |
| 327 | vk::DestroyInstance(dummy_instance, nullptr); // WORKAROUND |
| 328 | } |
| 329 | |
| 330 | // TODO: some new VUs soon |
| 331 | // VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT vs VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT |
| 332 | // VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT + VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT dependency |
| 333 | } |
| 334 | |
| 335 | TEST_F(VkLayerTest, InstanceBadValidationFlags) { |
| 336 | TEST_DESCRIPTION("Test creating instance with invalid VkValidationFlagsEXT."); |
| 337 | |
| 338 | if (!InstanceExtensionSupported(VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME)) { |
| 339 | printf("%s Did not find required instance extension %s.\n", kSkipPrefix, VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME); |
| 340 | return; |
| 341 | } |
| 342 | instance_extensions_.push_back(VK_EXT_VALIDATION_FLAGS_EXTENSION_NAME); |
| 343 | |
| 344 | auto ici = GetInstanceCreateInfo(); |
| 345 | |
| 346 | // the test framework should not be using VkValidationFlagsEXT itself |
| 347 | for (auto traversable_pnext = reinterpret_cast<const VkBaseInStructure*>(ici.pNext); traversable_pnext; |
| 348 | traversable_pnext = traversable_pnext->pNext) { |
| 349 | ASSERT_NE(traversable_pnext->sType, VK_STRUCTURE_TYPE_VALIDATION_FLAGS_EXT); |
| 350 | } |
| 351 | |
| 352 | VkValidationFlagsEXT validation_flags = {}; |
| 353 | validation_flags.sType = VK_STRUCTURE_TYPE_VALIDATION_FLAGS_EXT; |
| 354 | validation_flags.pNext = ici.pNext; |
| 355 | ici.pNext = &validation_flags; |
| 356 | |
| 357 | { |
| 358 | validation_flags.disabledValidationCheckCount = 1; |
| 359 | validation_flags.pDisabledValidationChecks = nullptr; |
| 360 | |
| 361 | // TODO: Crashes |
| 362 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkValidationFlagsEXT-pDisabledValidationChecks-parameter"); |
| 363 | // vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 364 | // Monitor().VerifyFound(); |
| 365 | // vk::DestroyInstance(dummy_instance, nullptr); // WORKAROUND |
| 366 | |
| 367 | const VkValidationCheckEXT bad_disable = (VkValidationCheckEXT)0x42; |
| 368 | validation_flags.pDisabledValidationChecks = &bad_disable; |
| 369 | |
| 370 | // TODO: Does not have a proper VUID |
| 371 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkValidationFlagsEXT-pDisabledValidationChecks-parameter"); |
| 372 | Monitor().SetDesiredFailureMsg(kErrorBit, "UNASSIGNED-GeneralParameterError-UnrecognizedValue"); |
| 373 | vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 374 | Monitor().VerifyFound(); |
| 375 | vk::DestroyInstance(dummy_instance, nullptr); // WORKAROUND |
| 376 | } |
| 377 | |
| 378 | { |
| 379 | validation_flags.disabledValidationCheckCount = 0; |
| 380 | |
| 381 | // TODO: Does not have a proper VUID |
| 382 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-VkValidationFlagsEXT-disabledValidationCheckCount-arraylength"); |
| 383 | Monitor().SetDesiredFailureMsg(kErrorBit, "parameter disabledValidationCheckCount must be greater than 0"); |
| 384 | vk::CreateInstance(&ici, nullptr, &dummy_instance); |
| 385 | Monitor().VerifyFound(); |
| 386 | vk::DestroyInstance(dummy_instance, nullptr); // WORKAROUND |
| 387 | } |
| 388 | |
| 389 | // TODO: some new VUs soon |
| 390 | // VK_VALIDATION_FEATURE_ENABLE_DEBUG_PRINTF_EXT vs VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT |
| 391 | // VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_RESERVE_BINDING_SLOT_EXT + VK_VALIDATION_FEATURE_ENABLE_GPU_ASSISTED_EXT dependency |
| 392 | } |
| 393 | |
| 394 | TEST_F(VkLayerTest, DestroyInstanceAllocationCallbacksCompatibility) { |
| 395 | TEST_DESCRIPTION("Test vkDestroyInstance with incompatible allocation callbacks."); |
| 396 | |
| 397 | const auto ici = GetInstanceCreateInfo(); |
| 398 | const VkAllocationCallbacks alloc_callbacks = {nullptr, &DummyAlloc, &DummyRealloc, |
| 399 | &DummyFree, &DummyInfoAlloc, &DummyInfoFree}; |
| 400 | |
| 401 | // TODO: also crashes Loader |
| 402 | //{ |
| 403 | // VkInstance instance; |
| 404 | // ASSERT_VK_SUCCESS(vk::CreateInstance(&ici, &alloc_callbacks, &instance)); |
| 405 | |
| 406 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-vkDestroyInstance-instance-00630"); |
| 407 | // vk::DestroyInstance(instance, nullptr); |
| 408 | // Monitor().VerifyFound(); |
| 409 | //} |
| 410 | |
| 411 | { |
| 412 | VkInstance instance; |
| 413 | ASSERT_VK_SUCCESS(vk::CreateInstance(&ici, nullptr, &instance)); |
| 414 | |
| 415 | Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-vkDestroyInstance-instance-00631"); |
| 416 | vk::DestroyInstance(instance, &alloc_callbacks); |
| 417 | Monitor().VerifyFound(); |
| 418 | } |
| 419 | } |
| 420 | |
| 421 | TEST_F(VkLayerTest, DestroyInstanceHandleLeak) { |
| 422 | TEST_DESCRIPTION("Test vkDestroyInstance while leaking a VkDevice object."); |
| 423 | |
| 424 | const auto ici = GetInstanceCreateInfo(); |
| 425 | |
| 426 | VkInstance instance; |
| 427 | ASSERT_VK_SUCCESS(vk::CreateInstance(&ici, nullptr, &instance)); |
| 428 | uint32_t physical_device_count = 1; |
| 429 | VkPhysicalDevice physical_device; |
| 430 | ASSERT_VK_SUCCESS(vk::EnumeratePhysicalDevices(instance, &physical_device_count, &physical_device)); |
| 431 | ASSERT_EQ(physical_device_count, 1); |
| 432 | |
| 433 | float dqci_priorities[] = {1.0}; |
| 434 | VkDeviceQueueCreateInfo dqci = {}; |
| 435 | dqci.sType = VK_STRUCTURE_TYPE_DEVICE_QUEUE_CREATE_INFO; |
| 436 | dqci.queueFamilyIndex = 0; |
| 437 | dqci.queueCount = 1; |
| 438 | dqci.pQueuePriorities = dqci_priorities; |
| 439 | |
| 440 | VkDeviceCreateInfo dci = {}; |
| 441 | dci.sType = VK_STRUCTURE_TYPE_DEVICE_CREATE_INFO; |
| 442 | dci.queueCreateInfoCount = 1; |
| 443 | dci.pQueueCreateInfos = &dqci; |
| 444 | |
| 445 | VkDevice leaked_device; |
| 446 | ASSERT_VK_SUCCESS(vk::CreateDevice(physical_device, &dci, nullptr, &leaked_device)); |
| 447 | |
| 448 | // TODO: Does not have a proper VUID assigned in object tracker |
| 449 | // Monitor().SetDesiredFailureMsg(kErrorBit, "VUID-vkDestroyInstance-instance-00629"); |
| 450 | Monitor().SetDesiredFailureMsg(kErrorBit, "UNASSIGNED-ObjectTracker-ObjectLeak"); |
| 451 | vk::DestroyInstance(instance, nullptr); |
| 452 | Monitor().VerifyFound(); |
| 453 | } |