自学内容网 自学内容网

OpenXR 超详细的spec

3.API 初始化

3.2 Function Pointers

XrResult xrGetInstanceProcAddr(
    XrInstance                                  instance,
    const char*                                 name,
    PFN_xrVoidFunction*                         function);

instance: XrInstance类型,可以是NULL,也可以是任何有效的instance;

name:待获取fp的函数名称;

function:返回的函数指针fp。

xrGetInstanceProcAddr的参数instance和name不同,返回的值也是不同,参考下表。

instance parametername parameterreturn value

*

NULL

undefined

invalid instance

*

undefined

NULL

xrEnumerateInstanceExtensionProperties

fp

NULL

xrEnumerateApiLayerProperties

fp

NULL

xrCreateInstance

fp

NULL

* (any name not covered above)

NULL

instance

core OpenXR function

fp1

instance

enabled extension function for instance

fp1

instance

* (any name not covered above)

NULL

  • 当参数instance是NULL时,但是name是xrEnumerateInstanceExtensionProperties/ xrEnumerateApiLayerProperties/ xrCreateInstance中任意一个,则返回对应name的函数fp。
  • 当instance是有效的对象时,如果name是core OpenXR function或者使能的扩展层extension的function,则会返回对应name的函数fp。
  • 如果name是不存在的函数名称,无论instance是否有效,都会返回NULL。

4. Instance

OpenXR instance是一个允许OpenXR application和runtime进行通信的句柄对象。application通过调用xrCreateInstance()和接收一个XrInstance对应的handle完成通信。

XrInstance对象存储和追踪OpenXR相关应用的状态,不需要在application的全局地址空间中存储任何这样的状态。由于instance对象对于application是不透明的,因此application可以创建多个instance,并安全封装application的OpenXR state。

OpenXR runtime可能会限制同时创建和使用XrInstance对象的数量,但他们必须支持每个进程至少创建和使用一个XrInstance对象。

4.1 API layers和Extensions

API layers或者扩展层可以提供附件功能。API Layer禁止添加或者修改OpenXR function的定义,而扩展层可以。

API layers函数集的使能要在创建instance时指定,这些API layers能够拦截(intercept)任何分发给该instance或者它的子类对象的函数。

API layers示例可以包含(但不限制于):

  • dump out OpenXR API的调用
  • 执行OpenXR校验。

4.1.1. xrEnumerateApiLayerProperties()

XrResult xrEnumerateApiLayerProperties(
    uint32_t                                    propertyCapacityInput,
    uint32_t*                                   propertyCountOutput,
    XrApiLayerProperties*                       properties);
  • 该函数决定哪些API layers集是可用的。
  • 参数propertyCapacityInput是属性array的容量值,0表示请求检索需要的capacity。
  • 参数propertyCountOutput是指向要写入属性数量的指针,或者是指向所需capacity的指针,以防propertyCapacityInput不足的情况。
  • 属性是指向XrApiLayerProperties结构体数组的指针,如果propertyCapacityInput=0,则可以为NULL。
  • 由于Runtime的外部操作,layers的可用列表在任何时间可能变化,因此该方法的使用相同的参数调用两次,返回结果可能不同。

一旦创建了instance,使能的layers在该instance的有效生命周期内都会继续enabled和valid,即使其中一些layer对未来的instance不可用。

4.1.2. XrApiLayerProperties结构体

typedef struct XrApiLayerProperties {
    XrStructureType    type;
    void*              next;
    char               layerName[XR_MAX_API_LAYER_NAME_SIZE];
    XrVersion          specVersion;
    uint32_t           layerVersion;
    char               description[XR_MAX_API_LAYER_DESCRIPTION_SIZE];
} XrApiLayerProperties;


原文地址:https://blog.csdn.net/lvyaer_1122/article/details/136412851

免责声明:本站文章内容转载自网络资源,如本站内容侵犯了原著者的合法权益,可联系本站删除。更多内容请关注自学内容网(zxcms.com)!