This is an automated email from the git hooks/post-receive script.
git pushed a commit to branch ecore-evas-gl-drm-offscreen
in repository efl.
View the commit online.
commit 1ff9998b1c741a8e41481c0c978e30dc17eb367d
Author: Cedric BAIL <[email protected]>
AuthorDate: Wed Dec 2 10:58:21 2026 -0600
evas:gl_drm: let the consumer ask if a render would be skipped
The engine skips a render when it has no free buffer, and evas counts
that render as drawn. What changed in it is only drawn again if the
consumer damages the canvas and renders once more, which no consumer
that renders from the main loop on its own can be expected to know.
Let the consumer ask first. The engine answers from gbm, which is the
only one to know how many buffers the surface has: Mesa makes four, but
nothing in gbm promises it, so a consumer that counted the frames it
holds would have to guess the number. A consumer that renders only
when it answers EINA_TRUE never has a render skipped, and the damage of
the frames stays what changed.
The answer is about the surface the canvas draws on now. A resize
reaches the engine with the render that follows it, so a consumer that
holds frames of the old size still gets "no" until that render ran.
Co-Authored-By: Claude Fable 5.2 <[email protected]>
---
.../evas/engines/gl_drm/Evas_Engine_GL_Drm.h | 15 ++++-
src/modules/evas/engines/gl_drm/evas_engine.c | 1 +
src/modules/evas/engines/gl_drm/evas_engine.h | 1 +
src/modules/evas/engines/gl_drm/evas_outbuf.c | 11 ++++
src/tests/evas/evas_test_gl_drm.c | 68 ++++++++++++++++++++++
5 files changed, 95 insertions(+), 1 deletion(-)
diff --git a/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h b/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h
index 40776e3acb..95fd14612e 100644
--- a/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h
+++ b/src/modules/evas/engines/gl_drm/Evas_Engine_GL_Drm.h
@@ -44,6 +44,9 @@ struct _Evas_Engine_Info_GL_Drm
struct
{
struct gbm_device *gbm;
+ /* Filled by the engine: the surface the canvas draws on, NULL while
+ * it has none. A resize makes another one. */
+ struct gbm_surface *surface;
Ecore_Drm2_Device *dev;
int bpp;
@@ -104,7 +107,10 @@ struct _Evas_Engine_Info_GL_Drm
* releasing a frame that followed a skipped render, the consumer has to
* add damage (evas_damage_rectangle_add()) and render to get them. The
* frame that comes then is a whole one. Holding fewer frames than the
- * engine has buffers is not noticed. */
+ * engine has buffers is not noticed. A consumer that does not want a
+ * render skipped asks func.frame_buffer_available() first and renders
+ * only when it answers EINA_TRUE: nothing is lost then, and the
+ * damage stays what changed. */
struct
{
void (*func)(void *data, Evas_Engine_GL_Drm_Frame *frame,
@@ -117,6 +123,13 @@ struct _Evas_Engine_Info_GL_Drm
struct
{
void (*frame_release)(Evas_Engine_GL_Drm_Frame *frame);
+ /* EINA_TRUE when a render started now has a buffer to draw in,
+ * EINA_FALSE when the engine would skip it. Only for a canvas with
+ * no device. The answer changes when a render delivers a frame,
+ * when the consumer releases one and when the canvas is resized, and
+ * it tells how many buffers the engine has without assuming a
+ * number. */
+ Eina_Bool (*frame_buffer_available)(const Evas_Engine_Info_GL_Drm *info);
} func;
};
diff --git a/src/modules/evas/engines/gl_drm/evas_engine.c b/src/modules/evas/engines/gl_drm/evas_engine.c
index 5aac9daa16..79eccfdc19 100644
--- a/src/modules/evas/engines/gl_drm/evas_engine.c
+++ b/src/modules/evas/engines/gl_drm/evas_engine.c
@@ -840,6 +840,7 @@ eng_output_info_setup(void *info)
einfo->render_mode = EVAS_RENDER_MODE_BLOCKING;
einfo->info.fd = -1;
einfo->func.frame_release = evas_outbuf_frame_release;
+ einfo->func.frame_buffer_available = evas_outbuf_frame_buffer_available;
}
static void *
diff --git a/src/modules/evas/engines/gl_drm/evas_engine.h b/src/modules/evas/engines/gl_drm/evas_engine.h
index 05d8805280..dca1037e64 100644
--- a/src/modules/evas/engines/gl_drm/evas_engine.h
+++ b/src/modules/evas/engines/gl_drm/evas_engine.h
@@ -139,6 +139,7 @@ void evas_outbuf_update_region_push(Outbuf *ob, RGBA_Image *update, int x, int y
void evas_outbuf_flush(Outbuf *ob, Tilebuf_Rect *surface_damage, Tilebuf_Rect *buffer_damage, Evas_Render_Mode render_mode);
void evas_outbuf_release_fb(void *, void *);
void evas_outbuf_frame_release(Evas_Engine_GL_Drm_Frame *frame);
+Eina_Bool evas_outbuf_frame_buffer_available(const Evas_Engine_Info_GL_Drm *info);
void evas_outbuf_damage_region_set(Outbuf *ob, Tilebuf_Rect *damage);
Evas_Engine_GL_Context* evas_outbuf_gl_context_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 08d0365346..728698d5a9 100644
--- a/src/modules/evas/engines/gl_drm/evas_outbuf.c
+++ b/src/modules/evas/engines/gl_drm/evas_outbuf.c
@@ -30,6 +30,7 @@ _evas_outbuf_gbm_surface_destroy(Outbuf *ob)
{
gbm_surface_destroy(ob->surface);
ob->surface = NULL;
+ ob->info->info.surface = NULL;
}
}
@@ -47,6 +48,8 @@ _evas_outbuf_gbm_surface_create(Outbuf *ob, int w, int h)
ob->surface =
gbm_surface_create(ob->info->info.gbm, w, h, format, flags);
+ ob->info->info.surface = ob->surface;
+
if (!ob->surface) ERR("Failed to create gbm surface");
}
@@ -153,6 +156,14 @@ evas_outbuf_frame_release(Evas_Engine_GL_Drm_Frame *released)
gbm_surface_release_buffer(frame->surface, frame->frame.bo);
}
+Eina_Bool
+evas_outbuf_frame_buffer_available(const Evas_Engine_Info_GL_Drm *info)
+{
+ if (!info->info.surface) return EINA_FALSE;
+
+ return !!gbm_surface_has_free_buffers(info->info.surface);
+}
+
static void
_evas_outbuf_frame_deliver(Outbuf *ob, Tilebuf_Rect *surface_damage)
{
diff --git a/src/tests/evas/evas_test_gl_drm.c b/src/tests/evas/evas_test_gl_drm.c
index dab89415ea..8c3206a0ce 100644
--- a/src/tests/evas/evas_test_gl_drm.c
+++ b/src/tests/evas/evas_test_gl_drm.c
@@ -497,6 +497,12 @@ _buffers_use_up(Test_Canvas *c)
return c->held_count;
}
+static Eina_Bool
+_buffer_available(Test_Canvas *c)
+{
+ return c->info->func.frame_buffer_available(c->info);
+}
+
static void
_frame_release_one(Test_Canvas *c)
{
@@ -675,6 +681,7 @@ EFL_START_TEST(evas_test_gl_drm_slow_consumer)
held = _buffers_use_up(c);
ck_assert_uint_eq(c->frame_count, held);
+ ck_assert(!_buffer_available(c));
_change_and_render(c);
_change_and_render(c);
@@ -684,6 +691,65 @@ EFL_START_TEST(evas_test_gl_drm_slow_consumer)
}
EFL_END_TEST
+/* A consumer that asks before it renders has no render skipped, and what
+ * the engine says tells where its buffers end. */
+EFL_START_TEST(evas_test_gl_drm_buffer_available)
+{
+ Test_Canvas *c = _canvas_new();
+ unsigned int held, before;
+
+ if (!c) return;
+
+ c->hold = EINA_TRUE;
+ ck_assert(_buffer_available(c));
+ while (_buffer_available(c))
+ {
+ ck_assert_uint_lt(c->held_count, HELD_MAX);
+ before = c->frame_count;
+ _change_and_render(c);
+ ck_assert_uint_eq(c->frame_count, before + 1);
+ }
+ held = c->held_count;
+ ck_assert_uint_ge(held, 2);
+
+ _frame_release_one(c);
+ ck_assert(_buffer_available(c));
+ _change_and_render(c);
+ ck_assert_uint_eq(c->held_count, held);
+ ck_assert(!_buffer_available(c));
+ ck_assert(_damage_covers(c, &c->mover_rect));
+
+ _canvas_free(c);
+}
+EFL_END_TEST
+
+/* Frames held across a resize do not take buffers of the new surface. The
+ * resize reaches the engine with the render that follows it. */
+EFL_START_TEST(evas_test_gl_drm_buffer_available_resize)
+{
+ Test_Canvas *c = _canvas_new();
+ unsigned int held;
+
+ if (!c) return;
+
+ c->hold = EINA_TRUE;
+ while (_buffer_available(c))
+ {
+ ck_assert_uint_lt(c->held_count, HELD_MAX);
+ _change_and_render(c);
+ }
+ held = c->held_count;
+ ck_assert_uint_ge(held, 2);
+
+ _canvas_resize(c, 160, 120);
+ _render(c);
+ ck_assert_uint_eq(c->frame_count, held + 1);
+ ck_assert(_buffer_available(c));
+
+ _canvas_free(c);
+}
+EFL_END_TEST
+
/* What changed while the engine could not draw comes with the next frame,
* which is a full one, whatever triggers that render. */
EFL_START_TEST(evas_test_gl_drm_slow_consumer_recovers)
@@ -980,6 +1046,8 @@ evas_test_gl_drm(TCase *tc)
tcase_add_test(tc, evas_test_gl_drm_frame_id);
tcase_add_test(tc, evas_test_gl_drm_no_callback);
tcase_add_test(tc, evas_test_gl_drm_slow_consumer);
+ tcase_add_test(tc, evas_test_gl_drm_buffer_available);
+ tcase_add_test(tc, evas_test_gl_drm_buffer_available_resize);
tcase_add_test(tc, evas_test_gl_drm_slow_consumer_recovers);
tcase_add_test(tc, evas_test_gl_drm_slow_consumer_damaged);
tcase_add_test(tc, evas_test_gl_drm_slow_consumer_steady);
--
To stop receiving notification emails like this one, please contact
the administrator of this repository.