summaryrefslogtreecommitdiff
path: root/thirdparty/openxr/src/loader/api_layer_interface.hpp
blob: b93e44584ef36ce65975140d001b049eb773f441 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
// Copyright (c) 2017-2022, The Khronos Group Inc.
// Copyright (c) 2017-2019 Valve Corporation
// Copyright (c) 2017-2019 LunarG, Inc.
//
// SPDX-License-Identifier: Apache-2.0 OR MIT
//
// Initial Author: Mark Young <marky@lunarg.com>
//

#pragma once

#include <string>
#include <vector>
#include <memory>

#include <openxr/openxr.h>

#include "loader_platform.hpp"
#include "loader_interfaces.h"

struct XrGeneratedDispatchTable;

class ApiLayerInterface {
   public:
    // Factory method
    static XrResult LoadApiLayers(const std::string& openxr_command, uint32_t enabled_api_layer_count,
                                  const char* const* enabled_api_layer_names,
                                  std::vector<std::unique_ptr<ApiLayerInterface>>& api_layer_interfaces);
    // Static queries
    static XrResult GetApiLayerProperties(const std::string& openxr_command, uint32_t incoming_count, uint32_t* outgoing_count,
                                          XrApiLayerProperties* api_layer_properties);
    static XrResult GetInstanceExtensionProperties(const std::string& openxr_command, const char* layer_name,
                                                   std::vector<XrExtensionProperties>& extension_properties);

    ApiLayerInterface(const std::string& layer_name, LoaderPlatformLibraryHandle layer_library,
                      std::vector<std::string>& supported_extensions, PFN_xrGetInstanceProcAddr get_instance_proc_addr,
                      PFN_xrCreateApiLayerInstance create_api_layer_instance);
    virtual ~ApiLayerInterface();

    PFN_xrGetInstanceProcAddr GetInstanceProcAddrFuncPointer() { return _get_instance_proc_addr; }
    PFN_xrCreateApiLayerInstance GetCreateApiLayerInstanceFuncPointer() { return _create_api_layer_instance; }

    std::string LayerName() { return _layer_name; }

    // Generated methods
    bool SupportsExtension(const std::string& extension_name) const;

   private:
    std::string _layer_name;
    LoaderPlatformLibraryHandle _layer_library;
    PFN_xrGetInstanceProcAddr _get_instance_proc_addr;
    PFN_xrCreateApiLayerInstance _create_api_layer_instance;
    std::vector<std::string> _supported_extensions;
};