noop: implement resource_get_handle
authorMarek Olšák <marek.olsak@amd.com>
Sun, 28 Aug 2016 16:50:19 +0000 (18:50 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Mon, 5 Sep 2016 14:12:04 +0000 (16:12 +0200)
X+DRI3 locks up if the returned handle is invalid.

src/gallium/drivers/noop/noop_pipe.c

index 25e0c1ff03613ac7f4a5ca572c9e768ddde40d2c..301301966ce862bd9aa4c56bfb04fece32ead40e 100644 (file)
@@ -134,13 +134,25 @@ static struct pipe_resource *noop_resource_from_handle(struct pipe_screen *scree
    return noop_resource;
 }
 
-static boolean noop_resource_get_handle(struct pipe_screen *screen,
+static boolean noop_resource_get_handle(struct pipe_screen *pscreen,
                                         struct pipe_context *ctx,
                                         struct pipe_resource *resource,
                                         struct winsys_handle *handle,
                                         unsigned usage)
 {
-   return FALSE;
+   struct noop_pipe_screen *noop_screen = (struct noop_pipe_screen*)pscreen;
+   struct pipe_screen *screen = noop_screen->oscreen;
+   struct pipe_resource *tex;
+   bool result;
+
+   /* resource_get_handle musn't fail. Just create something and return it. */
+   tex = screen->resource_create(screen, resource);
+   if (!tex)
+      return false;
+
+   result = screen->resource_get_handle(screen, NULL, tex, handle, usage);
+   pipe_resource_reference(&tex, NULL);
+   return result;
 }
 
 static void noop_resource_destroy(struct pipe_screen *screen,