Use wl_display_roundtrip instead of wl_display_dispatch

Bug #1211076 reported by Axel Davy
6
This bug affects 1 person
Affects Status Importance Assigned to Milestone
glmark2
Fix Committed
Undecided
Rafal Mielniczuk

Bug Description

In native-state-wayland.cpp,
In NativeStateWayland::flip, you call wl_display_dispatch.

In the wayland documentation, it says this function dispatches the event queue and block if there is no event.
With the current Mesa egl implementation eglSwapInterval(0) doesn't work, and everything is as if it was eglSwapInterval(1):
When commiting the buffer, egl put a listener to know when the frame is drawn (when the frame is drawn an event is sent).

I was testing an experimental implementation of eglSwapInterval(0), and glmark2 was blocked until I press keyboard or other things (ie send events). This is because eglSwapBuffers doesn't put any listener on the frame in this case, and then there is no pending event.

Commiting a buffer is not considered an event but a request, that is why wl_display_dispatch is not adapted.

Instead what you want is wl_display_roundtrip, that will process the pending requests (and the events) and then process the commit of the buffer in egl.

EDIT: krh told me that wl_display_flush would be better than wl_display_roundtrip. I've not tested, but it might be better to use it.

Related branches

Axel Davy (davyaxel)
description: updated
Axel Davy (davyaxel)
description: updated
Revision history for this message
Axel Davy (davyaxel) wrote :

I've learned that wl_display_dispatch implicitly flushes requests, so my comment about it was bad.
The only problem is that it waits at least one event to come.

Instead wl_display_roundtrip is similar to wl_display_dispatch, but use a sync request to receive an event and prevent blocking.

Revision history for this message
Rafal Mielniczuk (kruk87) wrote :

I also tested wl_display_flush, but then glmark2 was marked unresponsive by the compositor - showed busy cursor above (like no events were dispatched to the client).

So i think wl_display_roundtrip fits here perfectly, but maybe I miss something

Revision history for this message
Axel Davy (davyaxel) wrote :

wl_display_flush doesn't process incoming events (mouse, ...).

In theory it would be better (for CPU consumption and performance) to use wl_display_flush, and sometimes (for example 60 per second) use wl_display_roundtrip. I doubt however the performance impact is worth it (anyway egl would have to do a roundtrip if it doesn't get enough release events from the compositor, so every 2-3 frames, egl would do a roundtrip limited to egl events).

Replacing wl_display_dispatch by wl_display_roundtrip is the easiest solution and solves the issues.

Changed in glmark2:
status: New → Fix Committed
assignee: nobody → Rafal Mielniczuk (kruk87)
To post a comment you must log in.
This report contains Public information  
Everyone can see this information.

Other bug subscribers

Remote bug watches

Bug watches keep track of this bug in other bug trackers.