OpenXRVkFunctionLoader.cpp 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  1. /*
  2. * Copyright (c) Contributors to the Open 3D Engine Project.
  3. * For complete copyright and license terms please see the LICENSE at the root of this distribution.
  4. *
  5. * SPDX-License-Identifier: Apache-2.0 OR MIT
  6. *
  7. */
  8. #include <AzCore/std/containers/vector.h>
  9. #include <OpenXRVk/OpenXRVkFunctionLoader.h>
  10. #include <OpenXRVk_Platform.h>
  11. #include <OpenXRVk_Traits_Platform.h>
  12. namespace OpenXRVk
  13. {
  14. FunctionLoader::~FunctionLoader()
  15. {
  16. AZ_Assert(!m_moduleHandle, "Shutdown was not called before destroying this FunctionLoader");
  17. }
  18. bool FunctionLoader::Init()
  19. {
  20. const AZStd::vector<const char*> libs = {
  21. VULKAN_DLL,
  22. VULKAN_1_DLL
  23. };
  24. for (const char* libName : libs)
  25. {
  26. m_moduleHandle = AZ::DynamicModuleHandle::Create(libName);
  27. if (m_moduleHandle->Load(false))
  28. {
  29. break;
  30. }
  31. else
  32. {
  33. m_moduleHandle = nullptr;
  34. }
  35. }
  36. if (!m_moduleHandle)
  37. {
  38. AZ_Warning("Vulkan", false, "Could not find Vulkan library.");
  39. return false;
  40. }
  41. return InitInternal();
  42. }
  43. void FunctionLoader::Shutdown()
  44. {
  45. ShutdownInternal();
  46. if (m_moduleHandle)
  47. {
  48. m_moduleHandle->Unload();
  49. }
  50. m_moduleHandle = nullptr;
  51. }
  52. }