···11-// Copyright (c) 2017-2022, The Khronos Group Inc.
22-// Copyright (c) 2017 Valve Corporation
33-// Copyright (c) 2017 LunarG, Inc.
44-//
55-// SPDX-License-Identifier: Apache-2.0 OR MIT
66-//
77-// Initial Author: Mark Young <marky@lunarg.com>
88-//
99-1010-#pragma once
1111-1212-#include <openxr/openxr.h>
1313-1414-#ifdef __cplusplus
1515-extern "C" {
1616-#endif
1717-1818-// Forward declare.
1919-typedef struct XrApiLayerCreateInfo XrApiLayerCreateInfo;
2020-2121-// Function pointer prototype for the xrCreateApiLayerInstance function used in place of xrCreateInstance.
2222-// This function allows us to pass special API layer information to each layer during the process of creating an Instance.
2323-typedef XrResult(XRAPI_PTR *PFN_xrCreateApiLayerInstance)(const XrInstanceCreateInfo *info,
2424- const XrApiLayerCreateInfo *apiLayerInfo, XrInstance *instance);
2525-2626-// Loader/API Layer Interface versions
2727-// 1 - First version, introduces negotiation structure and functions
2828-#define XR_CURRENT_LOADER_API_LAYER_VERSION 1
2929-3030-// Loader/Runtime Interface versions
3131-// 1 - First version, introduces negotiation structure and functions
3232-#define XR_CURRENT_LOADER_RUNTIME_VERSION 1
3333-3434-// Version negotiation values
3535-typedef enum XrLoaderInterfaceStructs {
3636- XR_LOADER_INTERFACE_STRUCT_UNINTIALIZED = 0,
3737- XR_LOADER_INTERFACE_STRUCT_LOADER_INFO,
3838- XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST,
3939- XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST,
4040- XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO,
4141- XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO,
4242-} XrLoaderInterfaceStructs;
4343-4444-#define XR_LOADER_INFO_STRUCT_VERSION 1
4545-typedef struct XrNegotiateLoaderInfo {
4646- XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_LOADER_INFO
4747- uint32_t structVersion; // XR_LOADER_INFO_STRUCT_VERSION
4848- size_t structSize; // sizeof(XrNegotiateLoaderInfo)
4949- uint32_t minInterfaceVersion;
5050- uint32_t maxInterfaceVersion;
5151- XrVersion minApiVersion;
5252- XrVersion maxApiVersion;
5353-} XrNegotiateLoaderInfo;
5454-5555-#define XR_API_LAYER_INFO_STRUCT_VERSION 1
5656-typedef struct XrNegotiateApiLayerRequest {
5757- XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_REQUEST
5858- uint32_t structVersion; // XR_API_LAYER_INFO_STRUCT_VERSION
5959- size_t structSize; // sizeof(XrNegotiateApiLayerRequest)
6060- uint32_t layerInterfaceVersion; // CURRENT_LOADER_API_LAYER_VERSION
6161- XrVersion layerApiVersion;
6262- PFN_xrGetInstanceProcAddr getInstanceProcAddr;
6363- PFN_xrCreateApiLayerInstance createApiLayerInstance;
6464-} XrNegotiateApiLayerRequest;
6565-6666-#define XR_RUNTIME_INFO_STRUCT_VERSION 1
6767-typedef struct XrNegotiateRuntimeRequest {
6868- XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_RUNTIME_REQUEST
6969- uint32_t structVersion; // XR_RUNTIME_INFO_STRUCT_VERSION
7070- size_t structSize; // sizeof(XrNegotiateRuntimeRequest)
7171- uint32_t runtimeInterfaceVersion; // CURRENT_LOADER_RUNTIME_VERSION
7272- XrVersion runtimeApiVersion;
7373- PFN_xrGetInstanceProcAddr getInstanceProcAddr;
7474-} XrNegotiateRuntimeRequest;
7575-7676-// Function used to negotiate an interface betewen the loader and an API layer. Each library exposing one or
7777-// more API layers needs to expose at least this function.
7878-typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderApiLayerInterface)(const XrNegotiateLoaderInfo *loaderInfo,
7979- const char *apiLayerName,
8080- XrNegotiateApiLayerRequest *apiLayerRequest);
8181-8282-// Function used to negotiate an interface betewen the loader and a runtime. Each runtime should expose
8383-// at least this function.
8484-typedef XrResult(XRAPI_PTR *PFN_xrNegotiateLoaderRuntimeInterface)(const XrNegotiateLoaderInfo *loaderInfo,
8585- XrNegotiateRuntimeRequest *runtimeRequest);
8686-8787-// Forward declare.
8888-typedef struct XrApiLayerNextInfo XrApiLayerNextInfo;
8989-9090-#define XR_API_LAYER_NEXT_INFO_STRUCT_VERSION 1
9191-struct XrApiLayerNextInfo {
9292- XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_NEXT_INFO
9393- uint32_t structVersion; // XR_API_LAYER_NEXT_INFO_STRUCT_VERSION
9494- size_t structSize; // sizeof(XrApiLayerNextInfo)
9595- char layerName[XR_MAX_API_LAYER_NAME_SIZE]; // Name of API layer which should receive this info
9696- PFN_xrGetInstanceProcAddr nextGetInstanceProcAddr; // Pointer to next API layer's xrGetInstanceProcAddr
9797- PFN_xrCreateApiLayerInstance nextCreateApiLayerInstance; // Pointer to next API layer's xrCreateApiLayerInstance
9898- XrApiLayerNextInfo *next; // Pointer to the next API layer info in the sequence
9999-};
100100-101101-#define XR_API_LAYER_MAX_SETTINGS_PATH_SIZE 512
102102-#define XR_API_LAYER_CREATE_INFO_STRUCT_VERSION 1
103103-typedef struct XrApiLayerCreateInfo {
104104- XrLoaderInterfaceStructs structType; // XR_LOADER_INTERFACE_STRUCT_API_LAYER_CREATE_INFO
105105- uint32_t structVersion; // XR_API_LAYER_CREATE_INFO_STRUCT_VERSION
106106- size_t structSize; // sizeof(XrApiLayerCreateInfo)
107107- void *loaderInstance; // Pointer to the LoaderInstance class
108108- char settings_file_location[XR_API_LAYER_MAX_SETTINGS_PATH_SIZE]; // Location to the found settings file (or empty '\0')
109109- XrApiLayerNextInfo *nextInfo; // Pointer to the next API layer's Info
110110-} XrApiLayerCreateInfo;
111111-112112-#ifdef __cplusplus
113113-} // extern "C"
114114-#endif