api_layer_interface.hpp 2.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. // Copyright (c) 2017-2022, The Khronos Group Inc.
  2. // Copyright (c) 2017-2019 Valve Corporation
  3. // Copyright (c) 2017-2019 LunarG, Inc.
  4. //
  5. // SPDX-License-Identifier: Apache-2.0 OR MIT
  6. //
  7. // Initial Author: Mark Young <[email protected]>
  8. //
  9. #pragma once
  10. #include <string>
  11. #include <vector>
  12. #include <memory>
  13. #include <openxr/openxr.h>
  14. #include "loader_platform.hpp"
  15. #include "loader_interfaces.h"
  16. struct XrGeneratedDispatchTable;
  17. class ApiLayerInterface {
  18. public:
  19. // Factory method
  20. static XrResult LoadApiLayers(const std::string& openxr_command, uint32_t enabled_api_layer_count,
  21. const char* const* enabled_api_layer_names,
  22. std::vector<std::unique_ptr<ApiLayerInterface>>& api_layer_interfaces);
  23. // Static queries
  24. static XrResult GetApiLayerProperties(const std::string& openxr_command, uint32_t incoming_count, uint32_t* outgoing_count,
  25. XrApiLayerProperties* api_layer_properties);
  26. static XrResult GetInstanceExtensionProperties(const std::string& openxr_command, const char* layer_name,
  27. std::vector<XrExtensionProperties>& extension_properties);
  28. ApiLayerInterface(const std::string& layer_name, LoaderPlatformLibraryHandle layer_library,
  29. std::vector<std::string>& supported_extensions, PFN_xrGetInstanceProcAddr get_instance_proc_addr,
  30. PFN_xrCreateApiLayerInstance create_api_layer_instance);
  31. virtual ~ApiLayerInterface();
  32. PFN_xrGetInstanceProcAddr GetInstanceProcAddrFuncPointer() { return _get_instance_proc_addr; }
  33. PFN_xrCreateApiLayerInstance GetCreateApiLayerInstanceFuncPointer() { return _create_api_layer_instance; }
  34. std::string LayerName() { return _layer_name; }
  35. // Generated methods
  36. bool SupportsExtension(const std::string& extension_name) const;
  37. private:
  38. std::string _layer_name;
  39. LoaderPlatformLibraryHandle _layer_library;
  40. PFN_xrGetInstanceProcAddr _get_instance_proc_addr;
  41. PFN_xrCreateApiLayerInstance _create_api_layer_instance;
  42. std::vector<std::string> _supported_extensions;
  43. };