Android的VSYNC信号的理解必要性 [英] Understanding necessity of Android VSYNC signals

查看:3363
本文介绍了Android的VSYNC信号的理解必要性的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想更好地了解Android的显示子系统,但一个项目,仍然扑朔迷离对我来说是多么VSYNC信号的处理方式,以及为什么有那么多存在于首位。

I'm trying to get a better understanding of the Android display subsystem, but one item that's still confusing to me is how VSYNC signals are handled, and why so many exist in the first place.

机器人被设计成使用VSYNC在其核心,但也有它采用多个VSYNC信号。通过 https://source.android.com/devices/graphics/implement.html的垂直同步偏移部分中,存在其中图3 VSYNC信号的流程图:HW_VSYNC_0,VSYNC,和SF-VSYNC。据我所知,HW_VSYNC用于更新DispSync的时机,以及VSYNC和SF-VSYNC所使用的应用程序和surfaceflinger,但为什么是必要的,这些单独的信​​号呢?此外,如何偏移影响这些信号?是否有可在任何地方能够更好地解释了这个时序图?

Android is designed to use VSYNC at its core, but there are multiple VSYNC signals that it employs. Via https://source.android.com/devices/graphics/implement.html in the "VSYNC Offset" section, there is a flow diagram which diagrams three VSYNC signals: HW_VSYNC_0, VSYNC, and SF-VSYNC. I understand that HW_VSYNC is used to update the timing in DispSync, and that VSYNC and SF-VSYNC are used by the apps and surfaceflinger, but why are these individual signals necessary at all? Furthermore, how do the offsets impact these signals? Is there a timing diagram available anywhere which better explains this?

感谢您的帮助,您可以提供。

Thanks for any help you can offer.

推荐答案

要理解这些东西,这是最好的开始与的系统级图形架构文件,服用特别注意的的极品三重缓冲的部分和相关图表(在理想情况下将是一个GIF动画)。开头,如果应用程序启动VSYNC信号之间的中间绘制这句话是专门谈论DispSync。一旦你阅读,希望该设备的图形文档的DispSync节更有意义。

To understand this stuff, it's best to start with the System-Level Graphics Architecture document, taking particular note of The Need for Triple-Buffering section and the associated diagram (which ideally would be an animated GIF). The sentence that begins, "If the app starts rendering halfway between VSYNC signals" is talking specifically about DispSync. Once you've read that, hopefully the DispSync section of the device graphics doc makes more sense.

大部分设备没有配置DispSync偏移,所以实际上只有一个VSYNC信号。在下文中,我假设DispSync启用。

Most devices don't have DispSync offsets configured, so there is really only one VSYNC signal. In what follows I'm assuming DispSync is enabled.

硬件仅提供1个VSYNC信号,对应于所述主显示刷新。其他人都在软件中生成的SurfaceFlinger DispSync code,射击从实际VSYNC固定偏移量。一些聪明的软件是用来保持时序滑出的阶段。

The hardware only provides one VSYNC signal, corresponding to the primary display refresh. The others are generated in software by the SurfaceFlinger DispSync code, firing at fixed offsets from the actual VSYNC. Some clever software is used to keep the timings from slipping out of phase.

的信号被用于触发SurfaceFlinger组合物和应用程序的渲染。如果按照架构文档中的部分,你可以看到,这个规定的延迟时,应用程序呈现其内容之间的两帧,而当出现在屏幕上的内容。想想看这样的:有三次出现VSYNC的,应用程序绘制在V0,系统就组成的V1,以及组成的帧发送到显示器在V2 ​​

The signals are used to trigger SurfaceFlinger composition and app rendering. If you follow the section in the architecture document, you can see that this establishes two frames of latency between when the app renders its content, and when the content appears on the screen. Think of it like this: given three occurrences of VSYNC, the app draws at V0, the system does composition at V1, and the composed frame is sent to the display at V2.

如果你想跟踪触摸输入,也许是移动的地图在用户的手指周围,任何延迟将会按照用户的低迷触摸反应可以看出。的目标是最小化等待时间,提高了用户的体验。假设我们推迟了事件咯,所以应用程序在绘制V0.5,我们复合的V1.2,然后交换到显示在V2。通过偏移该应用和SF活性我们减少从2帧的总延迟至1.5,如下所示。

If you're trying to track touch input, perhaps moving a map around under the user's finger, any latency will be seen by the user as sluggish touch response. The goal is to minimize the latency to improve the user experience. Suppose we delayed the events slightly, so the app draws at V0.5, we composite at V1.2, and then swap to the display at V2. By offsetting the app and SF activity we reduce the total latency from 2 frames to 1.5, as shown below.

这就是DispSync是。在您链接在网页上的反馈框图,HW_VSYNC_0是硬件更新的物理显示器,VSYNC使该应用渲染,并SF_VSYNC导致SurfaceFlinger执行组合物。提到他们作为VSYNC是一个有点用词不当,但LCD面板指什么,因为VSYNC上可能是一个名不副实。

That's what DispSync is for. In the feedback diagram on the page you linked, HW_VSYNC_0 is the hardware refresh for the physical display, VSYNC causes the app to render, and SF_VSYNC causes SurfaceFlinger to perform composition. Referring to them as "VSYNC" is a bit of a misnomer, but on an LCD panel referring to anything as "VSYNC" is probably a misnomer.

的退休围栏时间戳在反馈线圈图指出是指一种巧妙的优化。因为我们没有做任何工作,对实际的硬件VSYNC,我们可以,如果我们把刷新信号关闭会略微高效。该DispSync code将改为使用时间戳从退休围栏(这是一个整体的其他讨论),看看它是不同步的情况,并且将暂时重新启用硬件信号,直到它回到正轨。

The "retire fence timestamps" noted in the feedback loop diagram refers to a clever optimization. Since we're not doing any work on the actual hardware VSYNC, we can be slightly more efficient if we turn the refresh signal off. The DispSync code will instead use the timestamps from retire fences (which is a whole other discussion) to see if it is falling out of sync, and will temporarily re-enable the hardware signal until it's back on track.

编辑::您可以看到的值是如何配置的<一个href="https://android.googlesource.com/device/lge/hammerhead/+/lollipop-release/BoardConfig.mk">Nexus 5 boardconfig 。请注意设置 VSYNC_EVENT_PHASE_OFFSET_NS SF_VSYNC_EVENT_PHASE_OFFSET_NS

you can see how the values are configured in the Nexus 5 boardconfig. Note the settings for VSYNC_EVENT_PHASE_OFFSET_NS and SF_VSYNC_EVENT_PHASE_OFFSET_NS.

这篇关于Android的VSYNC信号的理解必要性的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆