etnaviv: always try to create KMS side handles for imported resources
authorLucas Stach <l.stach@pengutronix.de>
Wed, 15 Jan 2020 11:07:44 +0000 (12:07 +0100)
committerLucas Stach <l.stach@pengutronix.de>
Mon, 9 Aug 2021 21:41:43 +0000 (23:41 +0200)
By creating the KMS side handles we allow GBM to return the proper KMS
side GEM handles for imported buffers. Always creating the KMS side
handles adds a bit of overhead, as we don't need them on all imported
resources, but seems like the most robust solution for now.

Cc: mesa-stable
Signed-off-by: Lucas Stach <l.stach@pengutronix.de>
Reviewed-by: Simon Ser <contact@emersion.fr>
Reviewed-by: Christian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/12018>

src/gallium/drivers/etnaviv/etnaviv_resource.c

index 3d1552e..aa47be8 100644 (file)
@@ -566,6 +566,16 @@ etna_resource_from_handle(struct pipe_screen *pscreen,
    if (!rsc->pending_ctx)
       goto fail;
 
+   if (screen->ro) {
+      struct pipe_resource *imp_prsc = prsc;
+      do {
+         etna_resource(imp_prsc)->scanout =
+               renderonly_create_gpu_import_for_resource(imp_prsc, screen->ro,
+                                                         NULL);
+         /* failure is expected for scanout incompatible buffers */
+      } while ((imp_prsc = imp_prsc->next));
+   }
+
    return prsc;
 
 fail: