mer-hybris / qt5-qpa-hwcomposer-plugin

Qt 5 QPA plugin for Droid hwcomposer
22 stars 45 forks source link

[hwcomposer] Move hwcomposer to its own thread. #30

Closed sletta closed 9 years ago

sletta commented 9 years ago

GL rendering on hwcomposer can be divided into three separate stages. GL draw call scheduling which is what the app is doing. Then the GPU kicks in and rasterizes the buffer. Once the buffer is ready, it is presented on the next vsync. In the current implementation these were all happening in sequence on the same thread. This gives us a very low threshold when trying to sustain 60 fps.

Instead change the implementation so we return fast from eglSwapBuffers, allowing the application to start scheduling the next frame right away. The hwcomposer will pick up the rendered buffer (with an acquire fence) and scheduling the composition on a separate thread. This means that waiting for the GPU to finish and presenting the buffer on the next vsync happens in parallel to the application scheduling the next frame. As the hybris hwcomposer uses 2 buffers by default, we'll allow for a queue of one GPU rendered buffer pending display in the hwcomposer.

For an application which completes its GL scheduling quickly this means very little, but for an application which spends 10+ms scheduling, we now allow it to hit 60fps even if the GPU rasterization time is close to 16ms.

This patch also introduces categorized logging into the v11 backend.

faenil commented 9 years ago

Awesome stuff! Thanks @sletta!