summaryrefslogtreecommitdiff
path: root/cube-video.c
diff options
context:
space:
mode:
authorRob Clark <robdclark@gmail.com>2017-05-03 13:05:26 -0400
committerRob Clark <robdclark@gmail.com>2017-05-08 13:48:45 -0400
commit0d8de4ce3a03f36af1817f9b0586d132ad2c5d2e (patch)
treec1092820d5860ecc28dc07d831fb257078baf557 /cube-video.c
parentb98f30e99d2650cde62c861eadb73e47e3a285ef (diff)
downloadkmscube-0d8de4ce3a03f36af1817f9b0586d132ad2c5d2e.tar.gz
video: fencing to avoid passing frame back to decoder too early
With atomic kms backend, userspace can get further ahead of the gpu. In the decoder, we unref the previous frame when retrieving the current frame. If userspace gets too far ahead, this can happen while the gpu is still sampling from the previous frame. Simple solution is add a fence. Signed-off-by: Rob Clark <robdclark@gmail.com> Reviewed-by: Eric Engestrom <eric.engestrom@imgtec.com>
Diffstat (limited to 'cube-video.c')
-rw-r--r--cube-video.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/cube-video.c b/cube-video.c
index 095544d..03bfb80 100644
--- a/cube-video.c
+++ b/cube-video.c
@@ -49,6 +49,8 @@ struct {
struct decoder *decoder;
int filenames_count, idx;
const char *filenames[32];
+
+ EGLSyncKHR last_fence;
} gl;
static const struct egl *egl = &gl.egl;
@@ -223,6 +225,12 @@ static void draw_cube_video(unsigned i)
ESMatrix modelview;
EGLImage frame;
+ if (gl.last_fence) {
+ egl->eglClientWaitSyncKHR(egl->display, gl.last_fence, 0, EGL_FOREVER_KHR);
+ egl->eglDestroySyncKHR(egl->display, gl.last_fence);
+ gl.last_fence = NULL;
+ }
+
frame = video_frame(gl.decoder);
if (!frame) {
/* end of stream */
@@ -289,6 +297,8 @@ static void draw_cube_video(unsigned i)
glDrawArrays(GL_TRIANGLE_STRIP, 12, 4);
glDrawArrays(GL_TRIANGLE_STRIP, 16, 4);
glDrawArrays(GL_TRIANGLE_STRIP, 20, 4);
+
+ gl.last_fence = egl->eglCreateSyncKHR(egl->display, EGL_SYNC_FENCE_KHR, NULL);
}
const struct egl * init_cube_video(const struct gbm *gbm, const char *filenames)
@@ -300,7 +310,10 @@ const struct egl * init_cube_video(const struct gbm *gbm, const char *filenames)
if (ret)
return NULL;
- if (egl_check(&gl.egl, glEGLImageTargetTexture2DOES))
+ if (egl_check(&gl.egl, glEGLImageTargetTexture2DOES) ||
+ egl_check(egl, eglCreateSyncKHR) ||
+ egl_check(egl, eglDestroySyncKHR) ||
+ egl_check(egl, eglClientWaitSyncKHR))
return NULL;
fnames = strdup(filenames);