From 28020ff57728d07ae0715fc15696b8fe40337b3d Mon Sep 17 00:00:00 2001 From: emersion Date: Tue, 29 May 2018 22:38:00 +0100 Subject: Only allow one modifier per DMA-BUF, split attributes struct in render/ --- include/wlr/render/dmabuf.h | 29 +++++++++++++++++++++++++++++ include/wlr/render/egl.h | 6 +++--- include/wlr/render/gles2.h | 2 +- include/wlr/render/interface.h | 6 +++--- include/wlr/render/wlr_renderer.h | 2 +- include/wlr/render/wlr_texture.h | 4 ++-- include/wlr/types/wlr_linux_dmabuf.h | 30 +++--------------------------- 7 files changed, 42 insertions(+), 37 deletions(-) create mode 100644 include/wlr/render/dmabuf.h (limited to 'include/wlr') diff --git a/include/wlr/render/dmabuf.h b/include/wlr/render/dmabuf.h new file mode 100644 index 00000000..2e13fe75 --- /dev/null +++ b/include/wlr/render/dmabuf.h @@ -0,0 +1,29 @@ +#ifndef WLR_RENDER_DMABUF_H +#define WLR_RENDER_DMABUF_H + +// So we don't have to pull in linux specific drm headers +#ifndef DRM_FORMAT_MOD_INVALID +#define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1) +#endif + +#define WLR_DMABUF_MAX_PLANES 4 + +enum wlr_dmabuf_attributes_flags { + WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT = 1, + WLR_DMABUF_ATTRIBUTES_FLAGS_INTERLACED = 2, + WLR_DMABUF_ATTRIBUTES_FLAGS_BOTTOM_FIRST = 4, +}; + +struct wlr_dmabuf_attributes { + int32_t width, height; + uint32_t format; + uint32_t flags; // enum wlr_dmabuf_attributes_flags + uint64_t modifier; + + int n_planes; + uint32_t offset[WLR_DMABUF_MAX_PLANES]; + uint32_t stride[WLR_DMABUF_MAX_PLANES]; + int fd[WLR_DMABUF_MAX_PLANES]; +}; + +#endif diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index 4d837138..7cd5c5ca 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -6,7 +6,7 @@ #include #include #include -#include +#include struct wlr_egl { EGLDisplay display; @@ -65,14 +65,14 @@ EGLImageKHR wlr_egl_create_image_from_wl_drm(struct wlr_egl *egl, * of the dmabuf with wlr_egl_check_import_dmabuf once first. */ EGLImageKHR wlr_egl_create_image_from_dmabuf(struct wlr_egl *egl, - struct wlr_dmabuf_buffer_attribs *attributes); + struct wlr_dmabuf_attributes *attributes); /** * Try to import the given dmabuf. On success return true false otherwise. * If this succeeds the dmabuf can be used for rendering on a texture */ bool wlr_egl_check_import_dmabuf(struct wlr_egl *egl, - struct wlr_dmabuf_buffer *dmabuf); + struct wlr_dmabuf_attributes *attributes); /** * Get the available dmabuf formats diff --git a/include/wlr/render/gles2.h b/include/wlr/render/gles2.h index 65bb36c1..866c6658 100644 --- a/include/wlr/render/gles2.h +++ b/include/wlr/render/gles2.h @@ -14,6 +14,6 @@ struct wlr_texture *wlr_gles2_texture_from_pixels(struct wlr_egl *egl, struct wlr_texture *wlr_gles2_texture_from_wl_drm(struct wlr_egl *egl, struct wl_resource *data); struct wlr_texture *wlr_gles2_texture_from_dmabuf(struct wlr_egl *egl, - struct wlr_dmabuf_buffer_attribs *attribs); + struct wlr_dmabuf_attributes *attribs); #endif diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index 2267d376..87b3c929 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -8,8 +8,8 @@ #include #include #include -#include #include +#include struct wlr_renderer_impl { void (*begin)(struct wlr_renderer *renderer, uint32_t width, @@ -31,7 +31,7 @@ struct wlr_renderer_impl { void (*wl_drm_buffer_get_size)(struct wlr_renderer *renderer, struct wl_resource *buffer, int *width, int *height); bool (*check_import_dmabuf)(struct wlr_renderer *renderer, - struct wlr_dmabuf_buffer *dmabuf); + struct wlr_dmabuf_attributes *attribs); int (*get_dmabuf_formats)(struct wlr_renderer *renderer, int **formats); int (*get_dmabuf_modifiers)(struct wlr_renderer *renderer, int format, uint64_t **modifiers); @@ -47,7 +47,7 @@ struct wlr_renderer_impl { struct wlr_texture *(*texture_from_wl_drm)(struct wlr_renderer *renderer, struct wl_resource *data); struct wlr_texture *(*texture_from_dmabuf)(struct wlr_renderer *renderer, - struct wlr_dmabuf_buffer_attribs *attribs); + struct wlr_dmabuf_attributes *attribs); void (*destroy)(struct wlr_renderer *renderer); void (*init_wl_display)(struct wlr_renderer *renderer, struct wl_display *wl_display); diff --git a/include/wlr/render/wlr_renderer.h b/include/wlr/render/wlr_renderer.h index 039bb66e..dd62944f 100644 --- a/include/wlr/render/wlr_renderer.h +++ b/include/wlr/render/wlr_renderer.h @@ -89,7 +89,7 @@ int wlr_renderer_get_dmabuf_modifiers(struct wlr_renderer *renderer, int format, * If this succeeds the dmabuf can be used for rendering on a texture */ bool wlr_renderer_check_import_dmabuf(struct wlr_renderer *renderer, - struct wlr_dmabuf_buffer *dmabuf); + struct wlr_dmabuf_attributes *attributes); /** * Reads out of pixels of the currently bound surface into data. `stride` is in * bytes. diff --git a/include/wlr/render/wlr_texture.h b/include/wlr/render/wlr_texture.h index 239fc51b..c1633820 100644 --- a/include/wlr/render/wlr_texture.h +++ b/include/wlr/render/wlr_texture.h @@ -5,7 +5,7 @@ #include #include #include -#include +#include struct wlr_renderer; struct wlr_texture_impl; @@ -33,7 +33,7 @@ struct wlr_texture *wlr_texture_from_wl_drm(struct wlr_renderer *renderer, * Create a new texture from a DMA-BUF. The returned texture is immutable. */ struct wlr_texture *wlr_texture_from_dmabuf(struct wlr_renderer *renderer, - struct wlr_dmabuf_buffer_attribs *attribs); + struct wlr_dmabuf_attributes *attribs); /** * Get the texture width and height. diff --git a/include/wlr/types/wlr_linux_dmabuf.h b/include/wlr/types/wlr_linux_dmabuf.h index 531e68ab..ea219020 100644 --- a/include/wlr/types/wlr_linux_dmabuf.h +++ b/include/wlr/types/wlr_linux_dmabuf.h @@ -1,40 +1,16 @@ #ifndef WLR_TYPES_WLR_LINUX_DMABUF_H #define WLR_TYPES_WLR_LINUX_DMABUF_H -#define WLR_LINUX_DMABUF_MAX_PLANES 4 - #include #include - -/* So we don't have to pull in linux specific drm headers */ -#ifndef DRM_FORMAT_MOD_INVALID -#define DRM_FORMAT_MOD_INVALID ((1ULL<<56) - 1) -#endif - -enum { - WLR_DMABUF_BUFFER_ATTRIBS_FLAGS_Y_INVERT = 1, - WLR_DMABUF_BUFFER_ATTRIBS_FLAGS_INTERLACED = 2, - WLR_DMABUF_BUFFER_ATTRIBS_FLAGS_BOTTOM_FIRST = 4, -}; - -struct wlr_dmabuf_buffer_attribs { - /* set via params_add */ - int n_planes; - uint32_t offset[WLR_LINUX_DMABUF_MAX_PLANES]; - uint32_t stride[WLR_LINUX_DMABUF_MAX_PLANES]; - uint64_t modifier[WLR_LINUX_DMABUF_MAX_PLANES]; - int fd[WLR_LINUX_DMABUF_MAX_PLANES]; - /* set via params_create */ - int32_t width, height; - uint32_t format; - uint32_t flags; -}; +#include struct wlr_dmabuf_buffer { struct wlr_renderer *renderer; struct wl_resource *buffer_resource; struct wl_resource *params_resource; - struct wlr_dmabuf_buffer_attribs attributes; + struct wlr_dmabuf_attributes attributes; + bool has_modifier; }; /** -- cgit v1.2.3