Sub 16ms render but missing swap

Emmanuel Gil Peyrot linkmauve at linkmauve.fr
Wed Oct 18 07:18:45 UTC 2023


Hi,

On Wed, Oct 18, 2023 at 12:00:45AM +0000, Joe M wrote:
> In a GLES app wired up to Weston/Wayland using EGL, we're calling `eglSwapBuffers` in a render loop that takes about 12-13ms to draw our content, based on CPU timing the run loop. However, the call to swap incurs a duration of around 20ms, meaning we're only hitting 30fps.

Most GPUs nowadays aren’t synchronous, your driver creates command
buffers which are sent to the GPU asynchronously, and then the GPU does
its work.  But unless you call glFinish() or wait on a sync object, you
won’t know at which time the GPU is actually done executing your
commands.  Most notably, eglSwapBufers() will not wait until your buffer
is fully drawn, so that you can start preparing for the next frame ahead
of time.

> I've investigated a little bit into using the presentation callback protocol, but my understanding is that the EGL display (part of drm-wayland in the mesa source IIRC) is itself already plugged in to the necessary Wayland callbacks such that using `eglSwapBuffers` is sufficient to maximize available draw time.
> I also tried enabling the profile flag in weston.ini that allows you to collect a trace, viewable in *wesgr*.  And I read Pekka's blog posts about these diagrams, but I still can't understand if our app is doing something suboptimally. I can't decipher what the wesgr diagram is saying.
> The other weston.ini knob I've tried is the `repaint` window, setting it to 12 or 13 to match our drawing loop. This seems to help sometimes but not in this case.
> A few questions:  1. What other avenues of investigation should I pursue for the swap delay? As in, why when I take 12 ms to render do I not see about 4ms for the swap call to return? My display is running in at 60hz.  2. Has EGL been optimized to use the available wayland callbacks and maximize available client drawing time?  3. Does EGL leverage "weston_direct_display_v1" when available? What's required to take advantage of it in the app code? (ie. run fullscreen?)
> Thanks!

-- 
Link Mauve


More information about the wayland-devel mailing list