gallium/noop: implement fences
authorMarek Olšák <marek.olsak@amd.com>
Fri, 6 Aug 2021 06:36:09 +0000 (02:36 -0400)
committerMarge Bot <eric+marge@anholt.net>
Mon, 9 Aug 2021 12:36:27 +0000 (12:36 +0000)
Acked-By: Mike Blumenkrantz <michael.blumenkrantz@gmail.com>
Acked-by: Pierre-Eric Pelloux-Prayer <pierre-eric.pelloux-prayer@amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12255>

src/gallium/auxiliary/driver_noop/noop_pipe.c

index a98567b..29a52d3 100644 (file)
@@ -310,8 +310,13 @@ static void noop_flush(struct pipe_context *ctx,
                        struct pipe_fence_handle **fence,
                        unsigned flags)
 {
-   if (fence)
-      *fence = NULL;
+   if (fence) {
+      struct pipe_reference *f = MALLOC_STRUCT(pipe_reference);
+      f->count = 1;
+
+      ctx->screen->fence_reference(ctx->screen, fence, NULL);
+      *fence = (struct pipe_fence_handle*)f;
+   }
 }
 
 static void noop_destroy_context(struct pipe_context *ctx)
@@ -488,6 +493,11 @@ static void noop_fence_reference(struct pipe_screen *screen,
                           struct pipe_fence_handle **ptr,
                           struct pipe_fence_handle *fence)
 {
+   if (pipe_reference((struct pipe_reference*)*ptr,
+                      (struct pipe_reference*)fence))
+      FREE(*ptr);
+
+   *ptr = fence;
 }
 
 static bool noop_fence_finish(struct pipe_screen *screen,