summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2018-07-10 16:53:12 -0400
committerChris Michael <cp.michael@samsung.com>2018-07-10 16:53:12 -0400
commit8cd3860d001d95a26ba016c01738abb3f015df49 (patch)
tree589574ffce2f81f1fe008bbd27e80a2880661d49
parent2668f6196e82f1d7d5bda6e10bb5cb27df01d768 (diff)
evas_drm: Trim the queue of buffers if we've had extra for too long
Summary: In fixing T7099 I've also allowed the buffer queue to grow quite large, so now we should prune it back if it's bigger than it needs to be for a long time. ref T7099 Depends on D6565 Reviewers: devilhorns Reviewed By: devilhorns Subscribers: cedric, #committers, zmike Tags: #efl Maniphest Tasks: T7099 Differential Revision: https://phab.enlightenment.org/D6566
-rw-r--r--src/modules/evas/engines/drm/evas_engine.h1
-rw-r--r--src/modules/evas/engines/drm/evas_outbuf.c28
2 files changed, 27 insertions, 2 deletions
diff --git a/src/modules/evas/engines/drm/evas_engine.h b/src/modules/evas/engines/drm/evas_engine.h
index 9d3a16d169..ea8a6cec03 100644
--- a/src/modules/evas/engines/drm/evas_engine.h
+++ b/src/modules/evas/engines/drm/evas_engine.h
@@ -67,6 +67,7 @@ struct _Outbuf
67 Eina_List *pending; 67 Eina_List *pending;
68 Eina_Rectangle *rects; 68 Eina_Rectangle *rects;
69 unsigned int rect_count; 69 unsigned int rect_count;
70 int unused_duration;
70 } priv; 71 } priv;
71 72
72 Eina_Bool alpha : 1; 73 Eina_Bool alpha : 1;
diff --git a/src/modules/evas/engines/drm/evas_outbuf.c b/src/modules/evas/engines/drm/evas_outbuf.c
index aa667a9c76..8b87c00661 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -9,6 +9,7 @@
9#define BLUE_MASK 0x0000ff 9#define BLUE_MASK 0x0000ff
10 10
11#define MAX_BUFFERS 10 11#define MAX_BUFFERS 10
12#define QUEUE_TRIM_DURATION 100
12 13
13static void 14static void
14_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count) 15_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count)
@@ -186,6 +187,7 @@ _outbuf_reconfigure(Outbuf *ob, int w, int h, int rotation, Outbuf_Depth depth)
186 ob->depth = depth; 187 ob->depth = depth;
187 ob->format = format; 188 ob->format = format;
188 ob->rotation = rotation; 189 ob->rotation = rotation;
190 ob->priv.unused_duration = 0;
189 191
190 EINA_LIST_FREE(ob->priv.fb_list, ofb) 192 EINA_LIST_FREE(ob->priv.fb_list, ofb)
191 _outbuf_fb_destroy(ofb); 193 _outbuf_fb_destroy(ofb);
@@ -198,14 +200,19 @@ _outbuf_fb_wait(Outbuf *ob)
198{ 200{
199 Eina_List *l; 201 Eina_List *l;
200 Outbuf_Fb *ofb, *best = NULL; 202 Outbuf_Fb *ofb, *best = NULL;
201 int best_age = -1; 203 int best_age = -1, num_required = 1, num_allocated = 0;
202 204
203 /* We pick the oldest available buffer to avoid using the same two 205 /* We pick the oldest available buffer to avoid using the same two
204 * repeatedly and then having the third be stale when we need it 206 * repeatedly and then having the third be stale when we need it
205 */ 207 */
206 EINA_LIST_FOREACH(ob->priv.fb_list, l, ofb) 208 EINA_LIST_FOREACH(ob->priv.fb_list, l, ofb)
207 { 209 {
208 if (ecore_drm2_fb_busy_get(ofb->fb)) continue; 210 num_allocated++;
211 if (ecore_drm2_fb_busy_get(ofb->fb))
212 {
213 num_required++;
214 continue;
215 }
209 if (ofb->valid && (ofb->age > best_age)) 216 if (ofb->valid && (ofb->age > best_age))
210 { 217 {
211 best = ofb; 218 best = ofb;
@@ -213,6 +220,23 @@ _outbuf_fb_wait(Outbuf *ob)
213 } 220 }
214 } 221 }
215 222
223 if (num_required < num_allocated)
224 ob->priv.unused_duration++;
225 else
226 ob->priv.unused_duration = 0;
227
228 /* If we've had unused buffers for longer than QUEUE_TRIM_DURATION, then
229 * destroy the oldest buffer (currently in best) and recursively call
230 * ourself to get the next oldest.
231 */
232 if (best && (ob->priv.unused_duration > QUEUE_TRIM_DURATION))
233 {
234 ob->priv.unused_duration = 0;
235 ob->priv.fb_list = eina_list_remove(ob->priv.fb_list, best);
236 _outbuf_fb_destroy(best);
237 best = _outbuf_fb_wait(ob);
238 }
239
216 return best; 240 return best;
217} 241}
218 242