summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2018-07-10 16:52:46 -0400
committerChris Michael <cp.michael@samsung.com>2018-07-10 16:52:46 -0400
commitf7fc06bf8648887aefd40a150f2ab4d42782de83 (patch)
tree30ad5a17258045299b48d8eb4f50e513c1c650ac
parent5d30f2b0b380be6be4d742009eb31685a98518e4 (diff)
evas_drm: Allocate buffers on demand
Summary: Instead of allocating a fixed number of buffers immediately, allocate buffers if needed to render to. Normally we only need 2 buffers, but we've been allocating 3 to handle worse case behaviour. As T7099 shows, this is not always enough. We now cap at a max of 10. For the normal case where we always use 2 this results in a slight memory reduction (1 buffer) and a slight renering load reduction because we pick the oldest buffer to render into. A future patch will trim the buffer queue if it's been too large for a long time. fix T7099 Depends on D6563 Reviewers: devilhorns Reviewed By: devilhorns Subscribers: cedric, #committers, zmike Tags: #efl Maniphest Tasks: T7099 Differential Revision: https://phab.enlightenment.org/D6564
-rw-r--r--src/modules/evas/engines/drm/evas_engine.h1
-rw-r--r--src/modules/evas/engines/drm/evas_outbuf.c82
2 files changed, 21 insertions, 62 deletions
diff --git a/src/modules/evas/engines/drm/evas_engine.h b/src/modules/evas/engines/drm/evas_engine.h
index ff5c10dbf5..c276b71092 100644
--- a/src/modules/evas/engines/drm/evas_engine.h
+++ b/src/modules/evas/engines/drm/evas_engine.h
@@ -62,7 +62,6 @@ struct _Outbuf
62 62
63 struct 63 struct
64 { 64 {
65 int num;
66 Eina_List *fb_list; 65 Eina_List *fb_list;
67 Outbuf_Fb *draw; 66 Outbuf_Fb *draw;
68 Ecore_Drm2_Output *output; 67 Ecore_Drm2_Output *output;
diff --git a/src/modules/evas/engines/drm/evas_outbuf.c b/src/modules/evas/engines/drm/evas_outbuf.c
index 2631d8ae38..dda005968d 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -69,9 +69,6 @@ Outbuf *
69_outbuf_setup(Evas_Engine_Info_Drm *info, int w, int h) 69_outbuf_setup(Evas_Engine_Info_Drm *info, int w, int h)
70{ 70{
71 Outbuf *ob; 71 Outbuf *ob;
72 Outbuf_Fb *ofb;
73 char *num;
74 int i = 0, fw = 0, fh = 0;
75 72
76 ob = calloc(1, sizeof(Outbuf)); 73 ob = calloc(1, sizeof(Outbuf));
77 if (!ob) return NULL; 74 if (!ob) return NULL;
@@ -88,39 +85,6 @@ _outbuf_setup(Evas_Engine_Info_Drm *info, int w, int h)
88 85
89 ob->priv.output = info->info.output; 86 ob->priv.output = info->info.output;
90 87
91 ob->priv.num = 3;
92
93 num = getenv("EVAS_DRM_BUFFERS");
94 if (num)
95 {
96 ob->priv.num = atoi(num);
97 if (ob->priv.num <= 0) ob->priv.num = 3;
98 else if (ob->priv.num > MAX_BUFFERS) ob->priv.num = MAX_BUFFERS;
99 }
100
101 if ((ob->rotation == 0) || (ob->rotation == 180))
102 {
103 fw = w;
104 fh = h;
105 }
106 else if ((ob->rotation == 90) || (ob->rotation == 270))
107 {
108 fw = h;
109 fh = w;
110 }
111
112 if ((!w) || (!h)) return ob;
113 for (i = 0; i < ob->priv.num; i++)
114 {
115 ofb = _outbuf_fb_create(ob, fw, fh);
116 if (!ofb)
117 {
118 WRN("Failed to create framebuffer %d", i);
119 continue;
120 }
121 ob->priv.fb_list = eina_list_append(ob->priv.fb_list, ofb);
122 }
123
124 return ob; 88 return ob;
125} 89}
126 90
@@ -170,7 +134,6 @@ void
170_outbuf_reconfigure(Outbuf *ob, int w, int h, int rotation, Outbuf_Depth depth) 134_outbuf_reconfigure(Outbuf *ob, int w, int h, int rotation, Outbuf_Depth depth)
171{ 135{
172 Outbuf_Fb *ofb; 136 Outbuf_Fb *ofb;
173 int i = 0, fw = 0, fh = 0;
174 unsigned int format = DRM_FORMAT_ARGB8888; 137 unsigned int format = DRM_FORMAT_ARGB8888;
175 138
176 switch (depth) 139 switch (depth)
@@ -225,29 +188,6 @@ _outbuf_reconfigure(Outbuf *ob, int w, int h, int rotation, Outbuf_Depth depth)
225 EINA_LIST_FREE(ob->priv.fb_list, ofb) 188 EINA_LIST_FREE(ob->priv.fb_list, ofb)
226 _outbuf_fb_destroy(ofb); 189 _outbuf_fb_destroy(ofb);
227 190
228 if ((ob->rotation == 0) || (ob->rotation == 180))
229 {
230 fw = w;
231 fh = h;
232 }
233 else if ((ob->rotation == 90) || (ob->rotation == 270))
234 {
235 fw = h;
236 fh = w;
237 }
238
239 if ((!w) || (!h)) return;
240 for (i = 0; i < ob->priv.num; i++)
241 {
242 ofb = _outbuf_fb_create(ob, fw, fh);
243 if (!ofb)
244 {
245 WRN("Failed to create framebuffer %d", i);
246 continue;
247 }
248 ob->priv.fb_list = eina_list_append(ob->priv.fb_list, ofb);
249 }
250
251 /* TODO: idle flush */ 191 /* TODO: idle flush */
252} 192}
253 193
@@ -277,10 +217,30 @@ _outbuf_fb_wait(Outbuf *ob)
277static Eina_Bool 217static Eina_Bool
278_outbuf_fb_assign(Outbuf *ob) 218_outbuf_fb_assign(Outbuf *ob)
279{ 219{
220 int fw = 0, fh = 0;
280 Outbuf_Fb *ofb; 221 Outbuf_Fb *ofb;
281 Eina_List *l; 222 Eina_List *l;
282 223
283 ob->priv.draw = _outbuf_fb_wait(ob); 224 ob->priv.draw = _outbuf_fb_wait(ob);
225 if (!ob->priv.draw)
226 {
227 EINA_SAFETY_ON_TRUE_RETURN_VAL(eina_list_count(ob->priv.fb_list) >= MAX_BUFFERS, EINA_FALSE);
228
229 if ((ob->rotation == 0) || (ob->rotation == 180))
230 {
231 fw = ob->w;
232 fh = ob->h;
233 }
234 else if ((ob->rotation == 90) || (ob->rotation == 270))
235 {
236 fw = ob->h;
237 fh = ob->w;
238 }
239 ob->priv.draw = _outbuf_fb_create(ob, fw, fh);
240 if (ob->priv.draw)
241 ob->priv.fb_list = eina_list_append(ob->priv.fb_list, ob->priv.draw);
242 }
243
284 while (!ob->priv.draw) 244 while (!ob->priv.draw)
285 { 245 {
286 ecore_drm2_fb_release(ob->priv.output, EINA_TRUE); 246 ecore_drm2_fb_release(ob->priv.output, EINA_TRUE);
@@ -311,7 +271,7 @@ _outbuf_state_get(Outbuf *ob)
311 if (!_outbuf_fb_assign(ob)) return MODE_FULL; 271 if (!_outbuf_fb_assign(ob)) return MODE_FULL;
312 272
313 age = ob->priv.draw->age; 273 age = ob->priv.draw->age;
314 if (age > ob->priv.num) return MODE_FULL; 274 if (age > 4) return MODE_FULL;
315 else if (age == 1) return MODE_COPY; 275 else if (age == 1) return MODE_COPY;
316 else if (age == 2) return MODE_DOUBLE; 276 else if (age == 2) return MODE_DOUBLE;
317 else if (age == 3) return MODE_TRIPLE; 277 else if (age == 3) return MODE_TRIPLE;