Documentation for <wlr/types/wlr_linux_dmabuf_v1.h>

Back to index

Table of contents

wlr_compositor_dmabuf_waiter_create()

void wlr_compositor_dmabuf_waiter_create(​struct wlr_compositor *compositor, enum wlr_surface_dmabuf_waiter_mode mode);

Initialize a compositor-wide buffer waiter, which will listen for new surfaces and attach buffer waiters to them.

struct wlr_dmabuf_v1_buffer

struct wlr_dmabuf_v1_buffer {
	struct wlr_buffer base;
	
	struct wl_resource *resource; // can be NULL if the client destroyed it
	struct wlr_dmabuf_attributes attributes;
	
	struct {
		struct wl_listener release;
	} WLR_PRIVATE;
};

wlr_dmabuf_v1_buffer_try_from_buffer_resource()

struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_try_from_buffer_resource(​struct wl_resource *buffer_resource);

Returns the struct wlr_dmabuf_buffer if the given resource was created via the linux-dmabuf buffer protocol or NULL otherwise.

wlr_linux_dmabuf_feedback_add_tranche()

struct wlr_linux_dmabuf_feedback_v1_tranche *wlr_linux_dmabuf_feedback_add_tranche(​struct wlr_linux_dmabuf_feedback_v1 *feedback);

Append a tranche at the end of the DMA-BUF feedback list.

Tranches must be added with decreasing priority.

struct wlr_linux_dmabuf_feedback_v1

struct wlr_linux_dmabuf_feedback_v1 {
	dev_t main_device;
	struct wl_array tranches; // struct wlr_linux_dmabuf_feedback_v1_tranche
};

wlr_linux_dmabuf_feedback_v1_finish()

void wlr_linux_dmabuf_feedback_v1_finish(​struct wlr_linux_dmabuf_feedback_v1 *feedback);

Release resources allocated by a DMA-BUF feedback object.

struct wlr_linux_dmabuf_feedback_v1_init_options

struct wlr_linux_dmabuf_feedback_v1_init_options {
	// Main renderer used by the compositor
	struct wlr_renderer *main_renderer;
	// Output on which direct scan-out is possible on the primary plane, or NULL
	struct wlr_output *scanout_primary_output;
	// Output layer feedback event, or NULL
	const struct wlr_output_layer_feedback_event *output_layer_feedback_event;
};

wlr_linux_dmabuf_feedback_v1_init_with_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);

struct wlr_linux_dmabuf_feedback_v1_tranche

struct wlr_linux_dmabuf_feedback_v1_tranche {
	dev_t target_device;
	uint32_t flags; // bitfield of enum zwp_linux_dmabuf_feedback_v1_tranche_flags
	struct wlr_drm_format_set formats;
};

struct wlr_linux_dmabuf_v1

struct wlr_linux_dmabuf_v1 {
	struct wl_global *global;
	
	struct {
		struct wl_signal destroy;
	} events;
	
	struct {
		struct wlr_linux_dmabuf_feedback_v1_compiled *default_feedback;
		struct wlr_drm_format_set default_formats; // for legacy clients
		struct wl_list surfaces; // wlr_linux_dmabuf_v1_surface.link
		
		int main_device_fd; // to sanity check FDs sent by clients, -1 if unavailable
		
		struct wl_listener display_destroy;
		
		bool (*check_dmabuf_callback)(​struct wlr_dmabuf_attributes *attribs, void *data);
		void *check_dmabuf_callback_data;
	} WLR_PRIVATE;
};

wlr_linux_dmabuf_v1_create()

struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create(​struct wl_display *display, uint32_t version, const struct wlr_linux_dmabuf_feedback_v1 *default_feedback);

Create the linux-dmabuf-v1 global.

Compositors using struct wlr_renderer should use wlr_linux_dmabuf_v1_create_with_renderer() instead.

wlr_linux_dmabuf_v1_create_with_renderer()

struct wlr_linux_dmabuf_v1 *wlr_linux_dmabuf_v1_create_with_renderer(​struct wl_display *display, uint32_t version, struct wlr_renderer *renderer);

Create the linux-dmabuf-v1 global.

The default DMA-BUF feedback is initialized from the struct wlr_renderer.

wlr_linux_dmabuf_v1_set_check_dmabuf_callback()

void wlr_linux_dmabuf_v1_set_check_dmabuf_callback(​struct wlr_linux_dmabuf_v1 *linux_dmabuf, bool (*callback)(​struct wlr_dmabuf_attributes *attribs, void *data), void *data);

Set the dmabuf import check callback

This can be used by consumers who want to implement specific dmabuf checks. Useful for users such as gamescope who do not use the rendering logic of wlroots.

wlr_linux_dmabuf_v1_set_surface_feedback()

bool wlr_linux_dmabuf_v1_set_surface_feedback(​struct wlr_linux_dmabuf_v1 *linux_dmabuf, struct wlr_surface *surface, const struct wlr_linux_dmabuf_feedback_v1 *feedback);

struct wlr_surface_dmabuf_waiter

struct wlr_surface_dmabuf_waiter {
	struct wlr_surface *surface;
	enum wlr_surface_dmabuf_waiter_mode mode;
	
	struct {
		struct wl_list commits; // wlr_surface_dmabuf_waiter_commit.link
		struct wl_listener client_commit;
	} WLR_PRIVATE;
};

A helper to wait for client buffers to be ready.

When attached to a surface, this helper will delay commits until the relevant GPU fences are materialized or work has completed, depending on mode. When set to WLR_SURFACE_DMABUF_WAITER_MODE_COMPLETE, this means that wlr_surface.events.commit will only fire when the GPU buffers attached to that commit are ready to be read.

wlr_surface_dmabuf_waiter_finish()

void wlr_surface_dmabuf_waiter_finish(​struct wlr_surface_dmabuf_waiter *waiter);

Clean up a buffer waiter.

Any pending commit waiting on GPU work to complete will be applied immediately.

wlr_surface_dmabuf_waiter_init()

void wlr_surface_dmabuf_waiter_init(​struct wlr_surface_dmabuf_waiter *waiter, struct wlr_surface *surface, enum wlr_surface_dmabuf_waiter_mode mode);

Initialize a buffer waiter for a surface.

Callers must call wlr_surface_dmabuf_waiter_finish() to unregister the waiter.

enum wlr_surface_dmabuf_waiter_mode

enum wlr_surface_dmabuf_waiter_mode {
	WLR_SURFACE_DMABUF_WAITER_MODE_AVAILABLE,
	WLR_SURFACE_DMABUF_WAITER_MODE_COMPLETE,
};