1// Copyright (c) 2017-2023, 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 <marky@lunarg.com>
8//
9
10#pragma once
11
12#include <string>
13#include <vector>
14#include <memory>
15
16#include <openxr/openxr.h>
17
18#include "loader_platform.hpp"
19#include "loader_interfaces.h"
20
21struct XrGeneratedDispatchTable;
22
23class ApiLayerInterface {
24 public:
25 // Factory method
26 static XrResult LoadApiLayers(const std::string& openxr_command, uint32_t enabled_api_layer_count,
27 const char* const* enabled_api_layer_names,
28 std::vector<std::unique_ptr<ApiLayerInterface>>& api_layer_interfaces);
29 // Static queries
30 static XrResult GetApiLayerProperties(const std::string& openxr_command, uint32_t incoming_count, uint32_t* outgoing_count,
31 XrApiLayerProperties* api_layer_properties);
32 static XrResult GetInstanceExtensionProperties(const std::string& openxr_command, const char* layer_name,
33 std::vector<XrExtensionProperties>& extension_properties);
34
35 ApiLayerInterface(const std::string& layer_name, LoaderPlatformLibraryHandle layer_library,
36 std::vector<std::string>& supported_extensions, PFN_xrGetInstanceProcAddr get_instance_proc_addr,
37 PFN_xrCreateApiLayerInstance create_api_layer_instance);
38 virtual ~ApiLayerInterface();
39
40 PFN_xrGetInstanceProcAddr GetInstanceProcAddrFuncPointer() { return _get_instance_proc_addr; }
41 PFN_xrCreateApiLayerInstance GetCreateApiLayerInstanceFuncPointer() { return _create_api_layer_instance; }
42
43 std::string LayerName() { return _layer_name; }
44
45 // Generated methods
46 bool SupportsExtension(const std::string& extension_name) const;
47
48 private:
49 std::string _layer_name;
50 LoaderPlatformLibraryHandle _layer_library;
51 PFN_xrGetInstanceProcAddr _get_instance_proc_addr;
52 PFN_xrCreateApiLayerInstance _create_api_layer_instance;
53 std::vector<std::string> _supported_extensions;
54};
55