Merge branch 'dmabuf-wait-helper' into 'master'

Add helper to wait for DMA-BUFs to be ready on surface commit

Closes #3026

See merge request wlroots/wlroots!4040
This commit is contained in:
Simon Ser 2026-01-25 01:12:35 +00:00
commit a3ee99e48f
2 changed files with 245 additions and 0 deletions

View file

@ -16,6 +16,7 @@
#include <wlr/render/dmabuf.h>
#include <wlr/render/drm_format_set.h>
struct wlr_compositor;
struct wlr_surface;
struct wlr_dmabuf_v1_buffer {
@ -134,4 +135,40 @@ struct wlr_linux_dmabuf_feedback_v1_init_options {
bool wlr_linux_dmabuf_feedback_v1_init_with_options(struct wlr_linux_dmabuf_feedback_v1 *feedback,
const struct wlr_linux_dmabuf_feedback_v1_init_options *options);
/**
* A helper to wait for client DMA-BUFs to be ready.
*
* When attached to a surface, this helper will delay commits until the GPU
* work is done. In other words, wlr_surface.events.commit will only fire when
* GPU buffers attached to that commit are ready.
*/
struct wlr_surface_dmabuf_waiter {
struct wlr_surface *surface;
// private state
struct wl_list commits; // wlr_surface_dmabuf_waiter_commit.link
struct wl_listener client_commit;
};
/**
* Initialize a DMA-BUF waiter for a surface.
*
* Callers must call wlr_surface_dmabuf_waiter_finish() to unregister the waiter.
*/
void wlr_surface_dmabuf_waiter_init(struct wlr_surface_dmabuf_waiter *waiter,
struct wlr_surface *surface);
/**
* Clean up a DMA-BUF waiter.
*
* Any pending commit waiting on GPU work to complete will be applied
* immediately.
*/
void wlr_surface_dmabuf_waiter_finish(struct wlr_surface_dmabuf_waiter *waiter);
/**
* Initialize a compositor-wide DMA-BUF waiter, which will listen for new
* surfaces and attach DMA-BUF surface waiters to them.
*/
void wlr_compositor_dmabuf_waiter_create(struct wlr_compositor *compositor);
#endif