gallium: trace: Add missing fence related wrappers
authorGuido Günther <agx@sigxcpu.org>
Fri, 29 Mar 2019 16:48:31 +0000 (17:48 +0100)
committerMarek Olšák <marek.olsak@amd.com>
Thu, 11 Apr 2019 01:31:16 +0000 (21:31 -0400)
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@sigxcpu.org>
Signed-off-by: Marek Olšák <marek.olsak@amd.com>
src/gallium/auxiliary/driver_trace/tr_context.c
src/gallium/auxiliary/driver_trace/tr_screen.c

index 479a987dfa6e9e6b798bcd805788dc52459a8d4a..70565db851d1600ebb90ba95670eda5db192263d 100644 (file)
@@ -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,
@@ -1949,6 +1991,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);
index b5bd3e11c465496c5a042ff2a19cae2232ee1506..e42aef635520bd64da68220f6f67eb15733688b5 100644 (file)
@@ -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);