From 95bb942aa7ff16e6aab2dd52971044874dc06077 Mon Sep 17 00:00:00 2001 From: Derek Foreman Date: Fri, 9 Sep 2016 13:35:22 -0500 Subject: [PATCH] gl_drm_ee: Remove repulsive hack and do proper gbm buffer accounting We no longer need this hack as we now have a way to properly handle the buffer locking in the engine, and don't currently deal with multi-head. --- src/modules/evas/engines/gl_drm/evas_engine.h | 2 +- src/modules/evas/engines/gl_drm/evas_outbuf.c | 38 +++++++++++-------- 2 files changed, 23 insertions(+), 17 deletions(-) diff --git a/src/modules/evas/engines/gl_drm/evas_engine.h b/src/modules/evas/engines/gl_drm/evas_engine.h index 6ad81df453..75fa7053a0 100644 --- a/src/modules/evas/engines/gl_drm/evas_engine.h +++ b/src/modules/evas/engines/gl_drm/evas_engine.h @@ -103,7 +103,6 @@ struct _Outbuf struct { - struct gbm_bo *bo[2]; Ecore_Drm2_Output *output; } priv; @@ -130,6 +129,7 @@ void *evas_outbuf_update_region_new(Outbuf *ob, int x, int y, int w, int h, int void evas_outbuf_update_region_push(Outbuf *ob, RGBA_Image *update, int x, int y, int w, int h); void evas_outbuf_update_region_free(Outbuf *ob, RGBA_Image *update); void evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *rects, Evas_Render_Mode render_mode); +void evas_outbuf_release_fb(void *, void *); Evas_Engine_GL_Context* evas_outbuf_gl_context_get(Outbuf *ob); void *evas_outbuf_egl_display_get(Outbuf *ob); diff --git a/src/modules/evas/engines/gl_drm/evas_outbuf.c b/src/modules/evas/engines/gl_drm/evas_outbuf.c index fb75313efd..0823aff80c 100644 --- a/src/modules/evas/engines/gl_drm/evas_outbuf.c +++ b/src/modules/evas/engines/gl_drm/evas_outbuf.c @@ -76,29 +76,31 @@ _evas_outbuf_fb_get(Outbuf *ob, struct gbm_bo *bo) return fb; } +void +_evas_outbuf_release_fb(void *ob_v, Ecore_Drm2_Fb *fb) +{ + struct gbm_bo *bo; + Outbuf *ob; + + ob = ob_v; + bo = ecore_drm2_fb_bo_get(fb); + gbm_surface_release_buffer(ob->surface, bo); +} + static void _evas_outbuf_buffer_swap(Outbuf *ob) { - Ecore_Drm2_Fb *fb; + struct gbm_bo *bo; + Ecore_Drm2_Fb *fb = NULL; - /* Repulsive hack: Right now we don't actually have a proper way to retire - * buffers because the ticker and the flip handler are out of sync, the - * flip handler is per output, fbs are submit to multiple outputs and may - * be denied (and re-queued) by any output they're supposed to be on. - * This will all be magically fixed when evas supports multiple target - * regions, but until then we do this: - * always have 2 buffers locked - */ - if (ob->priv.bo[1]) gbm_surface_release_buffer(ob->surface, ob->priv.bo[1]); - ob->priv.bo[1] = ob->priv.bo[0]; - ob->priv.bo[0] = gbm_surface_lock_front_buffer(ob->surface); - if (!ob->priv.bo[0]) + bo = gbm_surface_lock_front_buffer(ob->surface); + if (!bo) { - WRN("Could not lock front buffer: %m"); - return; + ecore_drm2_output_fb_release(ob->priv.output); + bo = gbm_surface_lock_front_buffer(ob->surface); } + if (bo) fb = _evas_outbuf_fb_get(ob, bo); - fb = _evas_outbuf_fb_get(ob, ob->priv.bo[0]); if (fb) { ecore_drm2_fb_flip(fb, ob->priv.output); @@ -390,6 +392,10 @@ evas_outbuf_new(Evas_Engine_Info_GL_Drm *info, int w, int h, Render_Engine_Swap_ ob->format = info->info.format; ob->priv.output = info->info.output; + ecore_drm2_output_release_handler_set(ob->priv.output, + _evas_outbuf_release_fb, + ob); + /* if ((num = getenv("EVAS_GL_DRM_VSYNC"))) */ /* ob->vsync = atoi(num); */