mirror of
https://gitlab.freedesktop.org/wayland/weston
synced 2024-10-16 00:47:26 +00:00
libweston: Add the ability to determine if a dmabuf is scanout-capable
Adds a new callback 'can_scanout_dmabuf' in weston_backend, which can be set by the back-end do determine if the buffer supplied can be imported directly by KMS. This patch adds a wrapper over it, 'weston_compositor_dmabuf_can_scanout' which is called before importing the dmabuf in the GPU if the direct_display dmabuf is being set. If that's true and the check failed, we refuse to create a wl_buffer. This patch avoids importing in the GPU. Signed-off-by: Marius Vlad <marius.vlad@collabora.com>
This commit is contained in:
parent
ebd10e512e
commit
5a701547a4
|
@ -95,6 +95,18 @@ struct weston_backend {
|
||||||
*/
|
*/
|
||||||
void (*device_changed)(struct weston_compositor *compositor,
|
void (*device_changed)(struct weston_compositor *compositor,
|
||||||
dev_t device, bool added);
|
dev_t device, bool added);
|
||||||
|
|
||||||
|
/** Verifies if the dmabuf can be used directly/scanned-out by the HW.
|
||||||
|
*
|
||||||
|
* @param compositor The compositor.
|
||||||
|
* @param buffer The dmabuf to verify.
|
||||||
|
*
|
||||||
|
* Determines if the buffer can be imported directly by the display
|
||||||
|
* controller/HW. Back-ends can use this to check if the supplied
|
||||||
|
* buffer can be scanned-out, as to void importing it into the GPU.
|
||||||
|
*/
|
||||||
|
bool (*can_scanout_dmabuf)(struct weston_compositor *compositor,
|
||||||
|
struct linux_dmabuf_buffer *buffer);
|
||||||
};
|
};
|
||||||
|
|
||||||
/* weston_head */
|
/* weston_head */
|
||||||
|
|
|
@ -7519,6 +7519,18 @@ weston_compositor_import_dmabuf(struct weston_compositor *compositor,
|
||||||
return renderer->import_dmabuf(compositor, buffer);
|
return renderer->import_dmabuf(compositor, buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
WL_EXPORT bool
|
||||||
|
weston_compositor_dmabuf_can_scanout(struct weston_compositor *compositor,
|
||||||
|
struct linux_dmabuf_buffer *buffer)
|
||||||
|
{
|
||||||
|
struct weston_backend *backend = compositor->backend;
|
||||||
|
|
||||||
|
if (backend->can_scanout_dmabuf == NULL)
|
||||||
|
return false;
|
||||||
|
|
||||||
|
return backend->can_scanout_dmabuf(compositor, buffer);
|
||||||
|
}
|
||||||
|
|
||||||
WL_EXPORT void
|
WL_EXPORT void
|
||||||
weston_version(int *major, int *minor, int *micro)
|
weston_version(int *major, int *minor, int *micro)
|
||||||
{
|
{
|
||||||
|
|
|
@ -79,6 +79,9 @@ weston_compositor_add_pending_output(struct weston_output *output,
|
||||||
bool
|
bool
|
||||||
weston_compositor_import_dmabuf(struct weston_compositor *compositor,
|
weston_compositor_import_dmabuf(struct weston_compositor *compositor,
|
||||||
struct linux_dmabuf_buffer *buffer);
|
struct linux_dmabuf_buffer *buffer);
|
||||||
|
bool
|
||||||
|
weston_compositor_dmabuf_can_scanout(struct weston_compositor *compositor,
|
||||||
|
struct linux_dmabuf_buffer *buffer);
|
||||||
void
|
void
|
||||||
weston_compositor_offscreen(struct weston_compositor *compositor);
|
weston_compositor_offscreen(struct weston_compositor *compositor);
|
||||||
|
|
||||||
|
|
|
@ -259,9 +259,18 @@ params_create_common(struct wl_client *client,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (buffer->direct_display) {
|
||||||
|
if (!weston_compositor_dmabuf_can_scanout(buffer->compositor,
|
||||||
|
buffer))
|
||||||
|
goto err_failed;
|
||||||
|
|
||||||
|
goto avoid_gpu_import;
|
||||||
|
}
|
||||||
|
|
||||||
if (!weston_compositor_import_dmabuf(buffer->compositor, buffer))
|
if (!weston_compositor_import_dmabuf(buffer->compositor, buffer))
|
||||||
goto err_failed;
|
goto err_failed;
|
||||||
|
|
||||||
|
avoid_gpu_import:
|
||||||
buffer->buffer_resource = wl_resource_create(client,
|
buffer->buffer_resource = wl_resource_create(client,
|
||||||
&wl_buffer_interface,
|
&wl_buffer_interface,
|
||||||
1, buffer_id);
|
1, buffer_id);
|
||||||
|
@ -368,6 +377,7 @@ linux_dmabuf_create_params(struct wl_client *client,
|
||||||
wl_resource_create(client,
|
wl_resource_create(client,
|
||||||
&zwp_linux_buffer_params_v1_interface,
|
&zwp_linux_buffer_params_v1_interface,
|
||||||
version, params_id);
|
version, params_id);
|
||||||
|
buffer->direct_display = false;
|
||||||
if (!buffer->params_resource)
|
if (!buffer->params_resource)
|
||||||
goto err_dealloc;
|
goto err_dealloc;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue