使用CPU而不是GPU的Andr​​oid渲染?而不是、CPU、GPU、oid

2023-09-05 09:03:58 作者:悲伤的季节

这真的很奇怪,在systrace的工具,当我看到被surfaceflinger绘图命令和窗口组成的执行,这是在CPU而不是在GPU上运行。但根据谷歌讲座,由罗曼盖伊,他们告诉记者,该组合物绘制命令与执行在GPU上执行。其GPU我的设备,即使如此,他们所使用的CPU核心。我想,如果CPU内核是免费的,然后它采用的CPU核心,否则使用的GPU。

It's really weird that in systrace tool when I saw the execution of drawing command and window composition by surfaceflinger, this is running on CPU but not on GPU. But as per google talk by Romain Guy, they told that this composition and execution of drawing commands are executed on GPU. My device having GPU, even then they are using CPU core. I think if CPU cores are free then it uses CPU core otherwise it uses GPU.

推荐答案

有三种方法可以做到表面组成:

There's three ways to do surface composition:

在使用叠加的飞机。最近的设备将组成多达四个平面作为像素正被发送到显示器。这是(通常)的最有效的方式来做到表面组成。它需要的DRM视频,因为目前尚无办法GLES撰写安全的表面。 在GPU,使用OpenGL ES。 SurfaceFlinger将回落到这一点,如果你有超过四架飞机组成。它也可用于虚拟显示器之类的东西 screenrecord 。在某些设备中,如果没有任何表面都在一个位被更新,硬件作曲家将使用GPU来构成表面,然后只显示单个缓冲区。这是更大的带宽效率比覆盖平面,如果没有改变(因为你没有通过所有的表面上运行,这意味着你需要更少的内存带宽,这意味着你可以时钟的事情时,这意味着你可以使用更少的电力)。 在CPU。没有人做这个了。 Using "overlay" planes. Most recent devices will compose up to four planes as the pixels are being sent to the display. This is (usually) the most efficient way to do surface composition. It's required for DRM video, because there's currently no way for GLES to compose "secure" surfaces. On the GPU, using OpenGL ES. SurfaceFlinger will fall back to this if you have more than four planes to compose. It's also used for virtual displays and things like screenrecord. On some devices, if none of the surfaces have been updated in a bit, the hardware composer will use the GPU to compose the surfaces and then just display the single buffer. This is more bandwidth-efficient than overlay planes if nothing is changing (because you don't have to run through all the surfaces, which means you need less memory bandwidth, which means you can clock things lower, which means you can use less power). On the CPU. Nobody does this anymore.

究竟它与设备之间的差异已经随着时间而演变。如果你想看看到底它在做什么,尽量亚行外壳dumpsys SurfaceFlinger 。硬件作曲家细节(底部附近)是最有趣的部分。您可能需要积极地滚动一些设备屏幕上同时运行命令,以避免GLES优化。

What exactly it does varies between devices and has evolved over time. If you want to see exactly what it's doing, try adb shell dumpsys SurfaceFlinger. The hardware composer details (near the bottom) are the most interesting part. You may need to actively scroll something on the device display while running the command to avoid the GLES optimization.

我猜想,你看到的是 prepare()设置()通话和缓冲区管理,而不是实际的像素组成,在你的systrace。

I would guess that you're seeing is the prepare() and set() calls and buffer management, not actual pixel composition, in your systrace.

更新:有一个非常好的写在的这个帖子。

Update: there's a really nice write-up in this post.

更新2:现在有完整的系统的概述中的 Android的系统级图形的文档。

Update 2: there's now an overview of the full system in the Android System-Level Graphics doc.