From 9ecfa4343a6d92fa057802a2911281d75a5a4f6f Mon Sep 17 00:00:00 2001 From: Simon Ser Date: Thu, 25 Mar 2021 21:07:58 +0100 Subject: [PATCH] render: remove wlr_texture_to_dmabuf This is unused in wlroots, and the use-cases for compositors are pretty niche since they can access the original DMA-BUF via the wlr_buffer. --- include/wlr/render/egl.h | 3 --- include/wlr/render/interface.h | 2 -- include/wlr/render/wlr_texture.h | 3 --- render/egl.c | 39 -------------------------------- render/gles2/texture.c | 29 ------------------------ render/wlr_texture.c | 8 ------- 6 files changed, 84 deletions(-) diff --git a/include/wlr/render/egl.h b/include/wlr/render/egl.h index 9a5bc76b..074c1653 100644 --- a/include/wlr/render/egl.h +++ b/include/wlr/render/egl.h @@ -46,7 +46,6 @@ struct wlr_egl { // Display extensions bool bind_wayland_display_wl; bool image_base_khr; - bool image_dma_buf_export_mesa; bool image_dmabuf_import_ext; bool image_dmabuf_import_modifiers_ext; @@ -63,8 +62,6 @@ struct wlr_egl { PFNEGLUNBINDWAYLANDDISPLAYWL eglUnbindWaylandDisplayWL; PFNEGLQUERYDMABUFFORMATSEXTPROC eglQueryDmaBufFormatsEXT; PFNEGLQUERYDMABUFMODIFIERSEXTPROC eglQueryDmaBufModifiersEXT; - PFNEGLEXPORTDMABUFIMAGEQUERYMESAPROC eglExportDMABUFImageQueryMESA; - PFNEGLEXPORTDMABUFIMAGEMESAPROC eglExportDMABUFImageMESA; PFNEGLDEBUGMESSAGECONTROLKHRPROC eglDebugMessageControlKHR; PFNEGLQUERYDISPLAYATTRIBEXTPROC eglQueryDisplayAttribEXT; PFNEGLQUERYDEVICESTRINGEXTPROC eglQueryDeviceStringEXT; diff --git a/include/wlr/render/interface.h b/include/wlr/render/interface.h index 88dc430b..f00a8d76 100644 --- a/include/wlr/render/interface.h +++ b/include/wlr/render/interface.h @@ -69,8 +69,6 @@ struct wlr_texture_impl { uint32_t stride, uint32_t width, uint32_t height, uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, const void *data); - bool (*to_dmabuf)(struct wlr_texture *texture, - struct wlr_dmabuf_attributes *attribs); void (*destroy)(struct wlr_texture *texture); }; diff --git a/include/wlr/render/wlr_texture.h b/include/wlr/render/wlr_texture.h index 4949d135..1dba2b9e 100644 --- a/include/wlr/render/wlr_texture.h +++ b/include/wlr/render/wlr_texture.h @@ -76,9 +76,6 @@ bool wlr_texture_write_pixels(struct wlr_texture *texture, uint32_t src_x, uint32_t src_y, uint32_t dst_x, uint32_t dst_y, const void *data); -bool wlr_texture_to_dmabuf(struct wlr_texture *texture, - struct wlr_dmabuf_attributes *attribs); - /** * Destroys this wlr_texture. */ diff --git a/render/egl.c b/render/egl.c index 9e6c366e..5074e684 100644 --- a/render/egl.c +++ b/render/egl.c @@ -241,14 +241,6 @@ struct wlr_egl *wlr_egl_create(EGLenum platform, void *remote_display) { "eglQueryDmaBufModifiersEXT"); } - if (check_egl_ext(display_exts_str, "EGL_MESA_image_dma_buf_export")) { - egl->exts.image_dma_buf_export_mesa = true; - load_egl_proc(&egl->procs.eglExportDMABUFImageQueryMESA, - "eglExportDMABUFImageQueryMESA"); - load_egl_proc(&egl->procs.eglExportDMABUFImageMESA, - "eglExportDMABUFImageMESA"); - } - if (check_egl_ext(display_exts_str, "EGL_WL_bind_wayland_display")) { egl->exts.bind_wayland_display_wl = true; load_egl_proc(&egl->procs.eglBindWaylandDisplayWL, @@ -699,37 +691,6 @@ const struct wlr_drm_format_set *wlr_egl_get_dmabuf_render_formats( return &egl->dmabuf_render_formats; } -bool wlr_egl_export_image_to_dmabuf(struct wlr_egl *egl, EGLImageKHR image, - int32_t width, int32_t height, uint32_t flags, - struct wlr_dmabuf_attributes *attribs) { - memset(attribs, 0, sizeof(struct wlr_dmabuf_attributes)); - - if (!egl->exts.image_dma_buf_export_mesa) { - return false; - } - - // Only one set of modifiers is returned for all planes - if (!egl->procs.eglExportDMABUFImageQueryMESA(egl->display, image, - (int *)&attribs->format, &attribs->n_planes, &attribs->modifier)) { - return false; - } - if (attribs->n_planes > WLR_DMABUF_MAX_PLANES) { - wlr_log(WLR_ERROR, "EGL returned %d planes, but only %d are supported", - attribs->n_planes, WLR_DMABUF_MAX_PLANES); - return false; - } - - if (!egl->procs.eglExportDMABUFImageMESA(egl->display, image, attribs->fd, - (EGLint *)attribs->stride, (EGLint *)attribs->offset)) { - return false; - } - - attribs->width = width; - attribs->height = height; - attribs->flags = flags; - return true; -} - static bool device_has_name(const drmDevice *device, const char *name) { for (size_t i = 0; i < DRM_NODE_MAX; i++) { if (!(device->available_nodes & (1 << i))) { diff --git a/render/gles2/texture.c b/render/gles2/texture.c index 94dcc022..fe7518d0 100644 --- a/render/gles2/texture.c +++ b/render/gles2/texture.c @@ -98,34 +98,6 @@ static bool gles2_texture_write_pixels(struct wlr_texture *wlr_texture, return true; } -static bool gles2_texture_to_dmabuf(struct wlr_texture *wlr_texture, - struct wlr_dmabuf_attributes *attribs) { - struct wlr_gles2_texture *texture = gles2_get_texture(wlr_texture); - - if (!texture->image) { - assert(texture->target == GL_TEXTURE_2D); - - if (!texture->renderer->egl->exts.image_base_khr) { - return false; - } - - texture->image = texture->renderer->egl->procs.eglCreateImageKHR( - texture->renderer->egl->display, texture->renderer->egl->context, EGL_GL_TEXTURE_2D_KHR, - (EGLClientBuffer)(uintptr_t)texture->tex, NULL); - if (texture->image == EGL_NO_IMAGE_KHR) { - return false; - } - } - - uint32_t flags = 0; - if (texture->inverted_y) { - flags |= WLR_DMABUF_ATTRIBUTES_FLAGS_Y_INVERT; - } - - return wlr_egl_export_image_to_dmabuf(texture->renderer->egl, texture->image, - wlr_texture->width, wlr_texture->height, flags, attribs); -} - static void gles2_texture_destroy(struct wlr_texture *wlr_texture) { if (wlr_texture == NULL) { return; @@ -152,7 +124,6 @@ static void gles2_texture_destroy(struct wlr_texture *wlr_texture) { static const struct wlr_texture_impl texture_impl = { .is_opaque = gles2_texture_is_opaque, .write_pixels = gles2_texture_write_pixels, - .to_dmabuf = gles2_texture_to_dmabuf, .destroy = gles2_texture_destroy, }; diff --git a/render/wlr_texture.c b/render/wlr_texture.c index e9a3e3b4..0fd79908 100644 --- a/render/wlr_texture.c +++ b/render/wlr_texture.c @@ -65,11 +65,3 @@ bool wlr_texture_write_pixels(struct wlr_texture *texture, return texture->impl->write_pixels(texture, stride, width, height, src_x, src_y, dst_x, dst_y, data); } - -bool wlr_texture_to_dmabuf(struct wlr_texture *texture, - struct wlr_dmabuf_attributes *attribs) { - if (!texture->impl->to_dmabuf) { - return false; - } - return texture->impl->to_dmabuf(texture, attribs); -}