-
Notifications
You must be signed in to change notification settings - Fork 341
DRM Explicit fencing #894
Comments
Here's the protocol proposal: https://patchwork.freedesktop.org/patch/177866/ |
The protocol has been merged: https://cgit.freedesktop.org/wayland/wayland-protocols/commit/?id=19ec5dcc4b1d57ce5dd8e400b5e9b4ec5791ff06 Note that we can implement this protocol before actually supporting DRM fences, because it provides a solution to a deficiency of the wl_buffer.release event (see https://gitlab.freedesktop.org/wayland/wayland/issues/46). |
After a lot more investigation to how this would be implemented, it turns out the nature of this problem is a lot different than I thought it was. Just so everyone is on the same page, a dma-fence is a kernel object which can signal the completion of asynchronous GPU operations. They are exposed to userspace using "sync files" which can be made up of multiple fences. Fortunately some kernel documentation for this exists: Now when it comes to implementing Passing a fence to the clientThis part isn't that tricky, but you still need to be a little careful. However, you need to be careful if you're using the client's buffer multiple times (e.g. spanning 2 outputs) or if you're going to hold onto the client's buffer longer than one frame. sync-files can be merged together, so it's not really that hard to do. Also note: You don't actually have to implement this to conform to the protocol. You can just use the Receiving a fence from the clientNow this is where things get complicated. The simple way
This is how Weston currently implements it, and would be considered the bare minimum for supporting explicit-sync. This adds some advantage for tracing, but doesn't really provide the real advantages of explicit-sync. A slow client is still capable of slowing the compositor's drawing down, and potentially missing vblank. The good, but complicated wayThis is where we actually make rendering decisions based of the status of the fence. However, this violates one of our fundamental assumptions: Consider this situation:
To solve this, instead of the current design of We also need to store ALL state tied to the surface commit, not just the buffer. Many protocol extensions affect rendering, so they need to be tied to the queue too. I don't particularly want to manage a queue of states inside of every single I believe my proposal should work for this, but there is still one pretty large nightmare protocol that still needs to be sorted: Anyway, that's my brain-dump about this protocol and hopefully justifies the changes I want to make in #1546. I asked a question about this on wayland-devel, so you can see the thread for some more info: https://lists.freedesktop.org/archives/wayland-devel/2019-February/040066.html |
Here's a test target for a client blocking the whole pipeline: https://gitlab.collabora.com/daniels/texture-atlas-test/blob/master/obnoxious-fbo-load.c#L92 Another one: https://github.com/ascent12/compositor-killer (Warning: don't try it at home) |
As a side note, explicit synchronization should also help with e.g. buggy Vulkan programs that mess up synchronization and submit jobs that never complete. Here's an example: https://gitlab.freedesktop.org/drm/amd/-/issues/702#note_650470 |
Another one of these new shiny graphics-related features I eventually want to get around to.
Basically, the purpose is to stop slow clients from stalling the graphics pipeline by controlling synchronization ourselves. It may also help with multi-GPU.
I'm not sure what impact this is going to have on the codebase, and how it may apply to non-DRM backends, if at all.
The
zwp_linux_explicit_synchronization_v1
protocol is used for this, although has not been merged at the time of writing.EGL_ANDROID_native_fence_sync is related.
It's also related to Vulkan Fences/Semaphores.
Extra links:
https://www.collabora.com/news-and-blog/blog/2016/09/13/mainline-explicit-fencing-part-1/
https://www.collabora.com/news-and-blog/blog/2016/10/18/mainline-explicit-fencing-part-2/
https://www.collabora.com/news-and-blog/blog/2017/01/26/mainline-explicit-fencing-part-3/
wlroots has migrated to gitlab.freedesktop.org. This issue has been moved to:
https://gitlab.freedesktop.org/wlroots/wlroots/-/issues/894
The text was updated successfully, but these errors were encountered: