高级用法
使用集合让一切井井有条
根据您的偏好保存内容并对其进行分类。
下面几部分概述了高级用法主题,在库正常运行期间不需要这些功能。
其他受支持的跟踪器
Tuning Fork 支持多种跟踪器。支持具有以下插桩键的跟踪器:
- 帧起始的间隔时间(称为
PACED_FRAME_TIME
)
- CPU 时间:帧起始与帧的 CPU 工作结束之间的间隔时间(称为
CPU_TIME
)
- GPU 时间:GPU 处理上一帧的时间(称为
GPU_TIME
)
- 原始帧时间,定义为 CPU 和 GPU 时间的上限(称为
RAW_FRAME_TIME
)。此选项与 PACED_FRAME_TIME
之间的区别在于,此选项不包含 Swappy 或 VSync 包含的任何等待时间。
您可以在参考文档中找到这些插桩键。当您启用 Android Frame Pacing 库时,系统会自动使用其中某些键,但如果您并未启用此库,就应显式使用这些键。
获取保真度参数
TFErrorCode TuningFork_getFidelityParameters(const CProtobufSerialization*
defaultParams, CProtobufSerialization* params, uint32_t
timeout_ms);
如果您在设置中将 fidelity_params_callback
传递给 TuningFork_init
,或库处于缩放模式下,您无需调用此函数。
此函数与服务器通信以检索保真度参数。发生以下情况之一后才会调用此函数:
- 系统检索了保真度参数,返回值为
TFERROR_OK
,且 returnedParams
存储了这些参数。在本例中,所有后续 tick 数据均与 returnedParams
相关联。
- 经过的毫秒数等于
timeout_ms
,并返回 TFERROR_TIMEOUT
的一个值。在本例中,所有后续 tick 数据均与 defaultFidelityParams
相关联。
您必须在此函数之前调用 TuningFork_init()
,并且必须在主线程以外的独立线程上调用它(如需了解适合您使用的实用函数,请参阅 TuningFork_startFidelityParamDownloadThread()
)。您可以再次调用此函数(例如,在加载关卡时),以再次从服务器检索保真度参数。这样,您就可以动态更新参数,而不是只能在启动时重新加载参数。如果下载了新的保真度参数或使用了新的默认值,则会提交之前的所有 tick 数据。
本页面上的内容和代码示例受内容许可部分所述许可的限制。Java 和 OpenJDK 是 Oracle 和/或其关联公司的注册商标。
最后更新时间 (UTC):2025-08-01。
[null,null,["最后更新时间 (UTC):2025-08-01。"],[],[],null,["# Advanced usage\n\nThe following sections outline advanced usage topics not needed for normal\noperation of the library.\n\nOther supported tracers\n-----------------------\n\nTuning Fork supports multiple tracers. Tracers with the following instrument\nkeys are supported:\n\n- Time between frame starts (called `PACED_FRAME_TIME`)\n- CPU Time: Time between the start of the frame and the end of the CPU work for the frame (called `CPU_TIME`)\n- GPU Time: Time for the previous frame to be handled by the GPU (called `GPU_TIME`)\n- The raw frame time, defined as the maximum of the CPU and GPU time (called `RAW_FRAME_TIME`). The difference between this option and `PACED_FRAME_TIME` is that this option does not include any wait time included by Swappy or VSync.\n\nYou can find these instrument keys in the\n[reference documentation](/games/sdk/reference/performance-tuner/custom-engine).\nSome of these keys are used automatically when you enable the Android Frame\nPacing library, but if you are not enabling this library, you should use them\nexplicitly.\n\nGet fidelity parameters\n-----------------------\n\n[`TFErrorCode TuningFork_getFidelityParameters(const CProtobufSerialization*\ndefaultParams, CProtobufSerialization* params, uint32_t\ntimeout_ms);`](/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork#tuningfork_getfidelityparameters)\n\nIf you pass `fidelity_params_callback` to `TuningFork_init` in settings or the\nlibrary is in scaled mode, you do not need to call this function.\n\nThis function contacts a server to retrieve fidelity parameters. It blocks until\none of the following occurs:\n\n- Fidelity parameters are retrieved, with a return value of `TFERROR_OK` and `returnedParams` store the parameters. In this case, all subsequent tick data is associated with `returnedParams`.\n- A number of milliseconds equal to `timeout_ms` passes, with a return value of `TFERROR_TIMEOUT`. In this case, all subsequent tick data is associated with `defaultFidelityParams`.\n\nYou must call `TuningFork_init()` before this function, and you must call it on\na separate thread from the main thread (see\n[`TuningFork_startFidelityParamDownloadThread()`](/games/sdk/reference/performance-tuner/custom-engine/group/tuningfork-extra#tuningfork_startfidelityparamdownloadthread)\nfor a utility function that does this for you). You can call this function\nagain, for example at level-loading time, to retrieve fidelity parameters from\nthe server again. This allows you to dynamically update parameters rather than\nhaving to reload them only at start-up. If new fidelity parameters are\ndownloaded or a new default is used, all previous tick data is submitted."]]