Monado OpenXR Runtime
oxr_api_negotiate.c File Reference

File for negotiating with the loader. More...

#include <stdio.h>
#include <string.h>
#include "xrt/xrt_compiler.h"
#include "xrt/xrt_config_os.h"
#include "util/u_debug.h"
#include "oxr_objects.h"
#include "oxr_logger.h"
#include "oxr_api_funcs.h"
#include "oxr_api_verify.h"
Include dependency graph for oxr_api_negotiate.c:

Macros

#define PRINT_NEGOTIATE(...)
 
#define ENTRY(funcName)
 Helper define for generating that GetInstanceProcAddr function. More...
 
#define ENTRY_IF(funcName, extraCondition, message)
 Helper define for generating that GetInstanceProcAddr function for conditionally-available functions. More...
 
#define ENTRY_IF_EXT(funcName, short_ext_name)    ENTRY_IF(funcName, inst->extensions.short_ext_name, "Required extension XR_" #short_ext_name " not enabled")
 Helper define for generating that GetInstanceProcAddr function for extension-provided functions. More...
 
#define ENTRY_IF_VERSION_AT_LEAST(funcName, major, minor)
 Helper define for generating that GetInstanceProcAddr function for functions that have been promoted to core in some OpenXR version. More...
 

Functions

XRAPI_ATTR XrResult XRAPI_CALL xrNegotiateLoaderRuntimeInterface (const XrNegotiateLoaderInfo *loaderInfo, XrNegotiateRuntimeRequest *runtimeRequest)
 
XRAPI_ATTR XrResult XRAPI_CALL oxr_xrEnumerateApiLayerProperties (uint32_t propertyCapacityInput, uint32_t *propertyCountOutput, XrApiLayerProperties *properties)
 OpenXR API function xrEnumerateApiLayerProperties. More...
 
static XrResult handle_non_null (struct oxr_instance *inst, struct oxr_logger *log, const char *name, PFN_xrVoidFunction *out_function)
 Handle a non-null instance pointer. More...
 
static XrResult handle_null (struct oxr_logger *log, const char *name, PFN_xrVoidFunction *out_function)
 Special case a null instance pointer. More...
 
XRAPI_ATTR XrResult XRAPI_CALL oxr_xrGetInstanceProcAddr (XrInstance instance, const char *name, PFN_xrVoidFunction *function)
 OpenXR API function xrGetInstanceProcAddr. More...
 

Detailed Description

Macro Definition Documentation

◆ ENTRY

#define ENTRY (   funcName)
Value:
do { \
if (strcmp(name, #funcName) == 0) { \
PFN_##funcName ret = &oxr_##funcName; \
*out_function = (PFN_xrVoidFunction)(ret); \
return XR_SUCCESS; \
} \
} while (false)

Helper define for generating that GetInstanceProcAddr function.

Use for functions that should be unconditionally available.

◆ ENTRY_IF

#define ENTRY_IF (   funcName,
  extraCondition,
  message 
)
Value:
do { \
if (strcmp(name, #funcName) == 0) { \
if (extraCondition) { \
PFN_##funcName ret = &oxr_##funcName; \
*out_function = (PFN_xrVoidFunction)(ret); \
return XR_SUCCESS; \
} \
return XR_ERROR_FUNCTION_UNSUPPORTED; \
} \
} while (false)

Helper define for generating that GetInstanceProcAddr function for conditionally-available functions.

Checks the extra condition to e.g. find out if the extension is enabled

◆ ENTRY_IF_EXT

#define ENTRY_IF_EXT (   funcName,
  short_ext_name 
)     ENTRY_IF(funcName, inst->extensions.short_ext_name, "Required extension XR_" #short_ext_name " not enabled")

Helper define for generating that GetInstanceProcAddr function for extension-provided functions.

Wraps ENTRY_IF for the common case.

Pass the function name and the (mixed-case) extension name without the leading XR_.

◆ ENTRY_IF_VERSION_AT_LEAST

#define ENTRY_IF_VERSION_AT_LEAST (   funcName,
  major,
  minor 
)
Value:
ENTRY_IF(funcName, (inst->openxr_version.major_minor >= XR_MAKE_VERSION(major, minor, 0)), \
("OpenXR version must be at least %d.%d.x", major, minor))
#define ENTRY_IF(funcName, extraCondition, message)
Helper define for generating that GetInstanceProcAddr function for conditionally-available functions.
Definition: oxr_api_negotiate.c:124

Helper define for generating that GetInstanceProcAddr function for functions that have been promoted to core in some OpenXR version.

Wraps ENTRY_IF for the common case.

Pass the function name and the OpenXR version the function has first been available in core.

◆ PRINT_NEGOTIATE

#define PRINT_NEGOTIATE (   ...)
Value:
do { \
if (debug_get_bool_option_negotiate()) { \
fprintf(stderr, __VA_ARGS__); \
} \
} while (false)

Function Documentation

◆ handle_non_null()

static XrResult handle_non_null ( struct oxr_instance inst,
struct oxr_logger log,
const char *  name,
PFN_xrVoidFunction *  out_function 
)
static

Handle a non-null instance pointer.

References ENTRY, ENTRY_IF_EXT, and ENTRY_IF_VERSION_AT_LEAST.

◆ handle_null()

static XrResult handle_null ( struct oxr_logger log,
const char *  name,
PFN_xrVoidFunction *  out_function 
)
static

Special case a null instance pointer.

References ENTRY, and oxr_error().