[Mesa-dev] [EGL android: accquire fence implementation] i965: Queue the buffer with a sync fence for Android OS
Rob Clark
robdclark at gmail.com
Mon Jul 10 12:06:02 UTC 2017
On Sun, Jul 9, 2017 at 10:11 PM, Zhongmin Wu <zhongmin.wu at intel.com> wrote:
> Before we queued the buffer with a invalid fence (-1), it will
> make some benchmarks failed to test such as flatland.
>
> Now we get the out fence during the flushing buffer and then pass
> it to SurfaceFlinger in eglSwapbuffer function.
>
> Change-Id: Ic0773c19788d612a98d1402f5b5619dab64c1bc2
> Tracked-On: https://jira01.devtools.intel.com/browse/OAM-43936
> Reported-On: https://bugs.freedesktop.org/show_bug.cgi?id=101655
> Signed-off-by: Zhongmin Wu <zhongmin.wu at intel.com>
> Reported-by: Li, Guangli <guangli.li at intel.com>
> Tested-by: Marathe, Yogesh <yogesh.marathe at intel.com>
> ---
> include/GL/internal/dri_interface.h | 2 ++
> src/egl/drivers/dri2/platform_android.c | 10 +++++++---
> src/mesa/drivers/dri/i965/brw_context.c | 7 ++++++-
> src/mesa/drivers/dri/i965/brw_context.h | 1 +
> src/mesa/drivers/dri/i965/intel_batchbuffer.c | 15 ++++++++++++++-
> src/mesa/drivers/dri/i965/intel_screen.c | 7 +++++++
> 6 files changed, 37 insertions(+), 5 deletions(-)
>
> diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
> index fc2d4bb..8760aec 100644
> --- a/include/GL/internal/dri_interface.h
> +++ b/include/GL/internal/dri_interface.h
> @@ -316,6 +316,8 @@ struct __DRI2flushExtensionRec {
> __DRIdrawable *drawable,
> unsigned flags,
> enum __DRI2throttleReason throttle_reason);
> +
> + int (*get_retrive_fd)(__DRIcontext *ctx);
> };
>
>
> diff --git a/src/egl/drivers/dri2/platform_android.c b/src/egl/drivers/dri2/platform_android.c
> index bfa20f8..844bb8d 100644
> --- a/src/egl/drivers/dri2/platform_android.c
> +++ b/src/egl/drivers/dri2/platform_android.c
> @@ -289,10 +289,14 @@ droid_window_enqueue_buffer(_EGLDisplay *disp, struct dri2_egl_surface *dri2_sur
> * is passed to queueBuffer, and the ANativeWindow implementation
> * is responsible for closing it.
> */
> - int fence_fd = -1;
> - dri2_surf->window->queueBuffer(dri2_surf->window, dri2_surf->buffer,
> - fence_fd);
>
> + _EGLContext *ctx = _eglGetCurrentContext();
> + struct dri2_egl_context *dri2_ctx = dri2_egl_context(ctx);
> +
> + int fd = -1;
> + fd = dri2_dpy->flush->get_retrive_fd(dri2_ctx->dri_context);
so from a quick look at this patch, I suspect this will cause gallium
drivers to start crashing without implementing this new function in
mesa/st. (Or is someone already working on that?)
Possibly an if(dri2_dpy->flush->get_retrive_fd) is sufficient
BR,
-R
> + dri2_surf->window->queueBuffer(dri2_surf->window, dri2_surf->buffer,
> + fd);
> dri2_surf->buffer->common.decRef(&dri2_surf->buffer->common);
> dri2_surf->buffer = NULL;
> dri2_surf->back = NULL;
> diff --git a/src/mesa/drivers/dri/i965/brw_context.c b/src/mesa/drivers/dri/i965/brw_context.c
> index 5433f90..f74ae91 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.c
> +++ b/src/mesa/drivers/dri/i965/brw_context.c
> @@ -940,6 +940,7 @@ brwCreateContext(gl_api api,
> brw->screen = screen;
> brw->bufmgr = screen->bufmgr;
>
> + brw->retrive_fd = -1;
> brw->gen = devinfo->gen;
> brw->gt = devinfo->gt;
> brw->is_g4x = devinfo->is_g4x;
> @@ -1176,8 +1177,12 @@ intelDestroyContext(__DRIcontext * driContextPriv)
>
> ralloc_free(brw);
> driContextPriv->driverPrivate = NULL;
> -}
>
> + if(brw->retrive_fd != -1) {
> + close(brw->retrive_fd);
> + brw->retrive_fd = -1;
> + }
> +}
> GLboolean
> intelUnbindContext(__DRIcontext * driContextPriv)
> {
> diff --git a/src/mesa/drivers/dri/i965/brw_context.h b/src/mesa/drivers/dri/i965/brw_context.h
> index dc4bc8f..8f277c3 100644
> --- a/src/mesa/drivers/dri/i965/brw_context.h
> +++ b/src/mesa/drivers/dri/i965/brw_context.h
> @@ -1217,6 +1217,7 @@ struct brw_context
>
> __DRIcontext *driContext;
> struct intel_screen *screen;
> + int retrive_fd;
> };
>
> /* brw_clear.c */
> diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> index 62d2fe8..31515b2 100644
> --- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> +++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
> @@ -648,9 +648,22 @@ do_flush_locked(struct brw_context *brw, int in_fence_fd, int *out_fence_fd)
> /* Add the batch itself to the end of the validation list */
> add_exec_bo(batch, batch->bo);
>
> + if(brw->retrive_fd != -1) {
> + close(brw->retrive_fd);
> + brw->retrive_fd = -1;
> + }
> +
> + int fd = -1;
> ret = execbuffer(dri_screen->fd, batch, hw_ctx,
> 4 * USED_BATCH(*batch),
> - in_fence_fd, out_fence_fd, flags);
> + in_fence_fd, &fd, flags);
> +
> + if(out_fence_fd != NULL) {
> + *out_fence_fd = fd;
> + brw->retrive_fd = dup(fd);
> + } else {
> + brw->retrive_fd = fd;
> + }
> }
>
> throttle(brw);
> diff --git a/src/mesa/drivers/dri/i965/intel_screen.c b/src/mesa/drivers/dri/i965/intel_screen.c
> index 7d320c0..2fd557b 100644
> --- a/src/mesa/drivers/dri/i965/intel_screen.c
> +++ b/src/mesa/drivers/dri/i965/intel_screen.c
> @@ -138,6 +138,12 @@ static const __DRItexBufferExtension intelTexBufferExtension = {
> .releaseTexBuffer = NULL,
> };
>
> +static int intel_dri2_get_retrive_fd(__DRIcontext *cPriv)
> +{
> + struct brw_context *brw = cPriv->driverPrivate;
> + return dup(brw->retrive_fd);
> +}
> +
> static void
> intel_dri2_flush_with_flags(__DRIcontext *cPriv,
> __DRIdrawable *dPriv,
> @@ -184,6 +190,7 @@ static const struct __DRI2flushExtensionRec intelFlushExtension = {
> .flush = intel_dri2_flush,
> .invalidate = dri2InvalidateDrawable,
> .flush_with_flags = intel_dri2_flush_with_flags,
> + .get_retrive_fd = intel_dri2_get_retrive_fd,
> };
>
> static struct intel_image_format intel_image_formats[] = {
> --
> 1.7.9.5
>
More information about the mesa-dev
mailing list