From 45ad3d47ade3ab45ac70c18d26b0cea193802821 Mon Sep 17 00:00:00 2001 From: Alexander Orzechowski Date: Fri, 24 Jun 2022 23:31:20 -0400 Subject: [PATCH] backend/drm: Report ZERO_COPY hint when direct scanning a client dmabuf. Since wlr_client_buffer is gone, we are now dealing with client dmabufs directly. --- backend/drm/drm.c | 4 +++- include/wlr/types/wlr_linux_dmabuf_v1.h | 6 ++++++ types/wlr_linux_dmabuf_v1.c | 4 ++++ 3 files changed, 13 insertions(+), 1 deletion(-) diff --git a/backend/drm/drm.c b/backend/drm/drm.c index 723beee24..2a2e0a412 100644 --- a/backend/drm/drm.c +++ b/backend/drm/drm.c @@ -16,6 +16,7 @@ #include #include #include +#include #include #include #include @@ -1508,7 +1509,8 @@ static void handle_page_flip(int fd, unsigned seq, * data between the GPUs, even if we were using the direct scanout * interface. */ - if (!drm->parent && plane->current_fb && false) { + if (!drm->parent && plane->current_fb && + wlr_dmabuf_v1_buffer_is_buffer(plane->current_fb->wlr_buf)) { present_flags |= WLR_OUTPUT_PRESENT_ZERO_COPY; } diff --git a/include/wlr/types/wlr_linux_dmabuf_v1.h b/include/wlr/types/wlr_linux_dmabuf_v1.h index 6b5f0d682..1222d8e29 100644 --- a/include/wlr/types/wlr_linux_dmabuf_v1.h +++ b/include/wlr/types/wlr_linux_dmabuf_v1.h @@ -34,6 +34,12 @@ struct wlr_dmabuf_v1_buffer { */ bool wlr_dmabuf_v1_resource_is_buffer(struct wl_resource *buffer_resource); +/** + * Returns true if the given buffer was created via the linux-dmabuf + * buffer protocol, false otherwise + */ +bool wlr_dmabuf_v1_buffer_is_buffer(struct wlr_buffer *buffer); + /** * Returns the struct wlr_dmabuf_buffer if the given resource was created * via the linux-dmabuf buffer protocol. diff --git a/types/wlr_linux_dmabuf_v1.c b/types/wlr_linux_dmabuf_v1.c index a124d5212..1b1b7b3b8 100644 --- a/types/wlr_linux_dmabuf_v1.c +++ b/types/wlr_linux_dmabuf_v1.c @@ -86,6 +86,10 @@ struct wlr_dmabuf_v1_buffer *wlr_dmabuf_v1_buffer_from_buffer_resource( static const struct wlr_buffer_impl buffer_impl; +bool wlr_dmabuf_v1_buffer_is_buffer(struct wlr_buffer *buffer) { + return buffer->impl == &buffer_impl; +} + static struct wlr_dmabuf_v1_buffer *dmabuf_v1_buffer_from_buffer( struct wlr_buffer *buffer) { assert(buffer->impl == &buffer_impl);