[Mesa-dev] [PATCH] gallium: trace: Add missing fence related wrappers

Guido Günther agx at sigxcpu.org
Tue Apr 9 11:33:12 UTC 2019


Hi,
On Fri, Mar 29, 2019 at 05:48:31PM +0100, Guido Günther wrote:
> Without that kmscube with GALLIUM_TRACE would segfault like:
> 
>   #0  0x0000000000000000 in  ()
>   #1  0x0000ffff8f311760 in dri2_create_fence_fd (_ctx=0xaaaae266b8b0, fd=10) at ../src/gallium/state_trackers/dri/dri_helpers.c:122
>   #2  0x0000ffff90788670 in dri2_create_sync (drv=0xaaaae2667910, disp=0xaaaae26691f0, type=12612, attrib_list=0xaaaae26b9290) at ../src/egl/drivers/dri2/egl_dri2.c:2993
>   #3  0x0000ffff90776a9c in _eglCreateSync (disp=0xaaaae26691f0, type=12612, attrib_list=0xaaaae26b9290, orig_is_EGLAttrib=0, invalid_type_error=12292) at ../src/egl/main/eglapi.c:1823
>   #4  0x0000ffff90776be4 in eglCreateSyncKHR (dpy=0xaaaae26691f0, type=12612, int_list=0xfffff662e828) at ../src/egl/main/eglapi.c:1848
> 
> Signed-off-by: Guido Günther <agx at sigxcpu.org>

These are similar to the already applied (thanks Lucas!) GALLIUM_DDEBUG
fixes:

    https://lists.freedesktop.org/archives/mesa-dev/2019-April/217422.html

but for GALLIUM_TRACE - just in case they looked to similar when flying
by.
Cheers,
 -- Guido

> ---
>  .../auxiliary/driver_trace/tr_context.c       | 44 +++++++++++++++++++
>  .../auxiliary/driver_trace/tr_screen.c        | 24 ++++++++++
>  2 files changed, 68 insertions(+)
> 
> diff --git a/src/gallium/auxiliary/driver_trace/tr_context.c b/src/gallium/auxiliary/driver_trace/tr_context.c
> index 7859a3395ca..9f3926a32a4 100644
> --- a/src/gallium/auxiliary/driver_trace/tr_context.c
> +++ b/src/gallium/auxiliary/driver_trace/tr_context.c
> @@ -1314,6 +1314,48 @@ trace_context_flush(struct pipe_context *_pipe,
>  }
>  
>  
> +static void
> +trace_context_create_fence_fd(struct pipe_context *_pipe,
> +                              struct pipe_fence_handle **fence,
> +                              int fd,
> +                              enum pipe_fd_type type)
> +{
> +   struct trace_context *tr_ctx = trace_context(_pipe);
> +   struct pipe_context *pipe = tr_ctx->pipe;
> +
> +   trace_dump_call_begin("pipe_context", "create_fence_fd");
> +
> +   trace_dump_arg(ptr, pipe);
> +   trace_dump_arg(int, fd);
> +   trace_dump_arg(uint, type);
> +
> +   pipe->create_fence_fd(pipe, fence, fd, type);
> +
> +   if (fence)
> +      trace_dump_ret(ptr, *fence);
> +
> +   trace_dump_call_end();
> +}
> +
> +
> +static void
> +trace_context_fence_server_sync(struct pipe_context *_pipe,
> +                                struct pipe_fence_handle *fence)
> +{
> +   struct trace_context *tr_ctx = trace_context(_pipe);
> +   struct pipe_context *pipe = tr_ctx->pipe;
> +
> +   trace_dump_call_begin("pipe_context", "fence_server_sync");
> +
> +   trace_dump_arg(ptr, pipe);
> +   trace_dump_arg(ptr, fence);
> +
> +   pipe->fence_server_sync(pipe, fence);
> +
> +   trace_dump_call_end();
> +}
> +
> +
>  static inline boolean
>  trace_context_generate_mipmap(struct pipe_context *_pipe,
>                                struct pipe_resource *res,
> @@ -1946,6 +1988,8 @@ trace_context_create(struct trace_screen *tr_scr,
>     TR_CTX_INIT(clear_depth_stencil);
>     TR_CTX_INIT(clear_texture);
>     TR_CTX_INIT(flush);
> +   TR_CTX_INIT(create_fence_fd);
> +   TR_CTX_INIT(fence_server_sync);
>     TR_CTX_INIT(generate_mipmap);
>     TR_CTX_INIT(texture_barrier);
>     TR_CTX_INIT(memory_barrier);
> diff --git a/src/gallium/auxiliary/driver_trace/tr_screen.c b/src/gallium/auxiliary/driver_trace/tr_screen.c
> index b5bd3e11c46..e42aef63552 100644
> --- a/src/gallium/auxiliary/driver_trace/tr_screen.c
> +++ b/src/gallium/auxiliary/driver_trace/tr_screen.c
> @@ -495,6 +495,29 @@ trace_screen_fence_reference(struct pipe_screen *_screen,
>  }
>  
>  
> +static int
> +trace_screen_fence_get_fd(struct pipe_screen *_screen,
> +                          struct pipe_fence_handle *fence)
> +{
> +   struct trace_screen *tr_scr = trace_screen(_screen);
> +   struct pipe_screen *screen = tr_scr->screen;
> +   int result;
> +
> +   trace_dump_call_begin("pipe_screen", "fence_get_fd");
> +
> +   trace_dump_arg(ptr, screen);
> +   trace_dump_arg(ptr, fence);
> +
> +   result = screen->fence_get_fd(screen, fence);
> +
> +   trace_dump_ret(int, result);
> +
> +   trace_dump_call_end();
> +
> +   return result;
> +}
> +
> +
>  static boolean
>  trace_screen_fence_finish(struct pipe_screen *_screen,
>                            struct pipe_context *_ctx,
> @@ -654,6 +677,7 @@ trace_screen_create(struct pipe_screen *screen)
>     SCR_INIT(resource_changed);
>     tr_scr->base.resource_destroy = trace_screen_resource_destroy;
>     tr_scr->base.fence_reference = trace_screen_fence_reference;
> +   SCR_INIT(fence_get_fd);
>     tr_scr->base.fence_finish = trace_screen_fence_finish;
>     SCR_INIT(memobj_create_from_handle);
>     SCR_INIT(memobj_destroy);
> -- 
> 2.20.1
> _______________________________________________
> mesa-dev mailing list
> mesa-dev at lists.freedesktop.org
> https://lists.freedesktop.org/mailman/listinfo/mesa-dev


More information about the mesa-dev mailing list