名称字符串

XR_ANDROID_recommended_resolution

扩展类型

实例扩展程序

已注册的扩展程序编号

462

修订版本

1

批准状态

未批准

扩展程序和版本依赖项

OpenXR 1.0

上次修改日期

IP 状态

创作贡献者

Trevor Debrechtabel,Google
Spencer Quin,Google
Lachlan Ford,Google
Vasiliy Baranov,Google

概览

此扩展程序允许运行时根据当前系统性能、设备散热或其他因素在建议的分辨率发生变化时通知应用。

此扩展程序通过以下方式修改规范:

  • 对于给定 systemIdviewConfigurationType,运行时可能会在实例的生命周期内从 xrEnumerateViewConfigurationViews 枚举中返回非相同的缓冲区内容。

XrEventDataRecommendedResolutionChangedANDROID 结构的定义如下:

typedef struct XrEventDataRecommendedResolutionChangedANDROID {
    XrStructureType    type;
    const void*        next;
} XrEventDataRecommendedResolutionChangedANDROID;

成员说明

  • type 是相应结构的 XrStructureType
  • nextNULL 或指向结构链中下一个结构的指针。核心 OpenXR 或此扩展程序中未定义任何此类结构。

收到 XrEventDataRecommendedResolutionChangedANDROID 事件结构表示建议的分辨率已更改。应用使用 xrEnumerateViewConfigurationViews 查询运行时以获取新的建议分辨率。

有效使用情况(隐式)

示例代码

以下示例代码演示了如何监听建议的分辨率更改事件。

// Created at app startup time.
XrInstance instance;
XrSystemId systemId; // Previously initialized.
uint32_t viewCountOutput; // Previously initialized.

// View configuration type the application uses.
XrViewConfigurationType viewConfigType;

// Poll events for recommended resolution changes.
XrEventDataBuffer event = {XR_TYPE_EVENT_DATA_BUFFER};
XrResult result = xrPollEvent(instance, &event);
if (result == XR_SUCCESS) {
  switch (event.type) {
    case XR_TYPE_EVENT_DATA_RECOMMENDED_RESOLUTION_CHANGED_ANDROID: {
        uint32_t viewCapacityInput = viewCountOutput;
        std::vector<XrViewConfigurationView> views(viewCapacityInput);
        result = xrEnumerateViewConfigurationViews(instance, systemId,
          viewConfigType, viewCapacityInput, &viewCountOutput, views.data());
        if(!XR_SUCCEEDED(result)) {
          // Handle error
        }

        // New recommended resolution is found in
        // views.recommendedImageRectWidth and views.recommendedImageRectHeight
        // Change the resolution for the viewConfigType
      break;
    }
    default:
      break;
  }
}

版本记录

  • 修订版本 1,2025 年 4 月 4 日 (Kenny Vercaemer)

    • 初始扩展程序说明