summaryrefslogtreecommitdiff
path: root/src/modules/evas/engines/drm/evas_outbuf.c
diff options
context:
space:
mode:
authorDerek Foreman <derekf@osg.samsung.com>2016-02-18 13:22:19 -0600
committerMike Blumenkrantz <zmike@osg.samsung.com>2016-02-18 15:50:15 -0500
commit5d7271683be0e790c1b845e7413a36992ebfb703 (patch)
treea1fddfd6a59a7ac9922c45676208fa687776c10c /src/modules/evas/engines/drm/evas_outbuf.c
parent1f576da49e662a563d16ea4915e485516aa2b4ee (diff)
ecore_drm: Change page flipping logic so we can't tear
Summary: Previously if we ever tried to queue up two page flips in less than a retrace interval (which can easily happen since the evas clock isn't based on vblank) we'd give up on ever using page flips again, and tear on every screen update. This fixes that by using a vblank callback for custom ticks and using page flips whenever possible. If a page flip fails it means a page flip raced with the vblank ticker, so we need to queue up that frame when the current page flip completes. This ensures that while we might drop interim frames, we will never lose the most recent. Now it should only be possible to tear if two ticks fire during the wait for a page flip to complete. This would result in rendering taking place in the front buffer. I don't think this can happen, but an error is logged if it does. Reviewers: zmike, devilhorns Subscribers: cedric, jpeg Differential Revision: https://phab.enlightenment.org/D3594
Diffstat (limited to '')
-rw-r--r--src/modules/evas/engines/drm/evas_outbuf.c31
1 files changed, 7 insertions, 24 deletions
diff --git a/src/modules/evas/engines/drm/evas_outbuf.c b/src/modules/evas/engines/drm/evas_outbuf.c
index 11d3dc6aab..64b3ba9a52 100644
--- a/src/modules/evas/engines/drm/evas_outbuf.c
+++ b/src/modules/evas/engines/drm/evas_outbuf.c
@@ -8,23 +8,6 @@
8#define GREEN_MASK 0x00ff00 8#define GREEN_MASK 0x00ff00
9#define BLUE_MASK 0x0000ff 9#define BLUE_MASK 0x0000ff
10 10
11static void
12_evas_outbuf_cb_pageflip(void *data)
13{
14 Outbuf *ob;
15 Ecore_Drm_Fb *fb;
16
17 if (!(ob = data)) return;
18
19 /* DBG("Outbuf Pagelip Done"); */
20
21 if ((fb = ob->priv.buffer[ob->priv.curr]))
22 fb->pending_flip = EINA_FALSE;
23
24 ob->priv.last = ob->priv.curr;
25 ob->priv.curr = (ob->priv.curr + 1) % ob->priv.num;
26}
27
28static void 11static void
29_evas_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count) 12_evas_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count)
30{ 13{
@@ -35,11 +18,11 @@ _evas_outbuf_buffer_swap(Outbuf *ob, Eina_Rectangle *rects, unsigned int count)
35 /* mark the fb as dirty */ 18 /* mark the fb as dirty */
36 ecore_drm_fb_dirty(buff, rects, count); 19 ecore_drm_fb_dirty(buff, rects, count);
37 20
38 /* if this buffer is not valid, we need to set it */
39 ecore_drm_fb_set(ob->info->info.dev, buff);
40
41 /* send this buffer to the crtc */ 21 /* send this buffer to the crtc */
42 ecore_drm_fb_send(ob->info->info.dev, buff, _evas_outbuf_cb_pageflip, ob); 22 ecore_drm_fb_send(ob->info->info.dev, buff, NULL, NULL);
23
24 ob->priv.last = ob->priv.curr;
25 ob->priv.curr = (ob->priv.curr + 1) % ob->priv.num;
43} 26}
44 27
45Outbuf * 28Outbuf *
@@ -62,8 +45,8 @@ evas_outbuf_setup(Evas_Engine_Info_Drm *info, int w, int h)
62 ob->destination_alpha = info->info.destination_alpha; 45 ob->destination_alpha = info->info.destination_alpha;
63 ob->vsync = info->info.vsync; 46 ob->vsync = info->info.vsync;
64 47
65 /* default to double-buffer */ 48 /* we must triple-buffer to prevent problems with the page flip handler */
66 ob->priv.num = 2; 49 ob->priv.num = 3;
67 50
68 /* check for buffer override */ 51 /* check for buffer override */
69 if ((num = getenv("EVAS_DRM_BUFFERS"))) 52 if ((num = getenv("EVAS_DRM_BUFFERS")))
@@ -98,7 +81,7 @@ evas_outbuf_setup(Evas_Engine_Info_Drm *info, int w, int h)
98 } 81 }
99 82
100 /* set the front buffer to be the one on the crtc */ 83 /* set the front buffer to be the one on the crtc */
101 ecore_drm_fb_set(info->info.dev, ob->priv.buffer[0]); 84 ecore_drm_fb_send(info->info.dev, ob->priv.buffer[0], NULL, NULL);
102 85
103 return ob; 86 return ob;
104} 87}