Codebase list kmscube / 0d8de4c
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> Rob Clark 7 years ago
1 changed file(s) with 14 addition(s) and 1 deletion(s). Raw diff Collapse all Expand all
4848 struct decoder *decoder;
4949 int filenames_count, idx;
5050 const char *filenames[32];
51
52 EGLSyncKHR last_fence;
5153 } gl;
5254
5355 static const struct egl *egl = &gl.egl;
222224 ESMatrix modelview;
223225 EGLImage frame;
224226
227 if (gl.last_fence) {
228 egl->eglClientWaitSyncKHR(egl->display, gl.last_fence, 0, EGL_FOREVER_KHR);
229 egl->eglDestroySyncKHR(egl->display, gl.last_fence);
230 gl.last_fence = NULL;
231 }
232
225233 frame = video_frame(gl.decoder);
226234 if (!frame) {
227235 /* end of stream */
288296 glDrawArrays(GL_TRIANGLE_STRIP, 12, 4);
289297 glDrawArrays(GL_TRIANGLE_STRIP, 16, 4);
290298 glDrawArrays(GL_TRIANGLE_STRIP, 20, 4);
299
300 gl.last_fence = egl->eglCreateSyncKHR(egl->display, EGL_SYNC_FENCE_KHR, NULL);
291301 }
292302
293303 const struct egl * init_cube_video(const struct gbm *gbm, const char *filenames)
299309 if (ret)
300310 return NULL;
301311
302 if (egl_check(&gl.egl, glEGLImageTargetTexture2DOES))
312 if (egl_check(&gl.egl, glEGLImageTargetTexture2DOES) ||
313 egl_check(egl, eglCreateSyncKHR) ||
314 egl_check(egl, eglDestroySyncKHR) ||
315 egl_check(egl, eglClientWaitSyncKHR))
303316 return NULL;
304317
305318 fnames = strdup(filenames);