# get\_gpu\_headroom

Source: [https://docs.qualcomm.com/doc/80-PK177-134Y/topic/enhanced_qape_get_gpu_headroom.html](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/enhanced_qape_get_gpu_headroom.html)

返回最近“持续时间”秒内可用的平均/最小 GPU 裕量百分比。应用程序使用 get\_gpu\_headroom() API 获取有关历史应用程序渲染工作负载的反馈，以知悉工作负载是否与 SoC 上的 GPU 绑定。此 API 旨在帮助提供应用程序内容的 GPU 性能信息和帮助驱动工作负载，以及提供其他 API 来确保平稳持续的 UX 性能（最大限度减少帧丢失，降低 UI 延迟）。应用程序可以监控温度。如果移动设备温度接近温控限值，则会进一步检查工作负载是否与 GPU 绑定，以此判断降低 GPU 负载是否有助于减轻温升状态 (&lt;= LIGHT)，从而改善持久性能。

注释： 当温升调节时，GPU 余量计算考虑了最大 GPU 频率调节。

注释： 此 API 只适用于游戏，因为游戏被视为 GPU 任务繁重的用例。对于常规应用程序，此 API 返回 -1。

## 参数

| 参数 | API 类型 | 数据类型 | 说明 |
| --- | --- | --- | --- |
| duration | Java | int | 定义需要持续获取几秒的信息。支持的最大持续时间为 60 s。<br><br><br>                <br>有效范围为 1 至 60。 |
| duration | 原生 | uint8 | 定义需要持续获取几秒的信息。支持的最大持续时间为 60 s。<br><br><br>                <br>有效范围为 1 至 60。 |
| 类型 | Java | boolean | 支持两种模式：<br><br><br>                <ul class="ul"><br>                  <li class="li">FALSE - 最低 GPU 余量，以持续时间秒数表示。</li><br><br>                  <li class="li">TRUE - 平均 GPU 余量，以持续时间秒数表示。</li><br><br>                </ul> |
| 类型 | 原生 | boolean | 支持两种模式：<br><br><br>                <ul class="ul"><br>                  <li class="li">FALSE - 最低 GPU 余量，以持续时间秒数表示。</li><br><br>                  <li class="li">TRUE - 平均 GPU 余量，以持续时间秒数表示。</li><br><br>                </ul> |
|  |  |  |  |

## 返回结果

| API 类型 | 返回结果 | 说明 |
| --- | --- | --- |
| Java | int | <ul class="ul"><br>                  <li class="li">≥0 - 余量</li><br><br>                  <li class="li">-1 – 请求 GPU 余量失败</li><br><br>                  <li class="li">-2 - 建立会话失败；在此 API 之前调用 <a href="https://docs.qualcomm.com/doc/80-PK177-134Y/topic/qape_set_pkg.html">set_pkg</a></li><br><br>                </ul> |
| 原生 | int8 | <ul class="ul"><br>                  <li class="li">≥0 - 余量</li><br><br>                  <li class="li">-1 – 请求 GPU 余量失败</li><br><br>                  <li class="li">-2 - 建立会话失败；在此 API 之前调用 <a href="https://docs.qualcomm.com/doc/80-PK177-134Y/topic/qape_set_pkg.html">set_pkg</a></li><br><br>                </ul> |
|  |  |  |

**上一级主题：** [增强型 QAPE API](https://docs.qualcomm.com/doc/80-PK177-134Y/topic/enhanced_qape_api.html)

Last Published: Jun 22, 2023

[Previous Topic
QAPE 增强型管理器](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134Y/topics/enhanced_qape_manager.md) [Next Topic
示例代码](https://docs.qualcomm.com/bundle/publicresource/80-PK177-134Y/topics/qape_example_code.md)