We try to avoid sharing all resources with KMS side of renderonly, as this
adds some overhead that isn't really needed for most resources. If
someone tries to validate a resource for scanout, this is a good indication
that the sharing with the KMS side is actually needed.

Signed-off-by: Lucas Stach <l.st...@pengutronix.de>
---
 .../drivers/etnaviv/etnaviv_resource.c        | 22 +++++++++++++++++++
 1 file changed, 22 insertions(+)

diff --git a/src/gallium/drivers/etnaviv/etnaviv_resource.c 
b/src/gallium/drivers/etnaviv/etnaviv_resource.c
index c00912880309..cd846e3ae36e 100644
--- a/src/gallium/drivers/etnaviv/etnaviv_resource.c
+++ b/src/gallium/drivers/etnaviv/etnaviv_resource.c
@@ -624,6 +624,27 @@ etna_resource_get_handle(struct pipe_screen *pscreen,
    }
 }
 
+static bool
+etna_check_resource_capability(struct pipe_screen *pscreen,
+                               struct pipe_resource *prsc,
+                               unsigned bind)
+{
+   struct etna_screen *screen = etna_screen(pscreen);
+   struct etna_resource *rsc = etna_resource(prsc);
+
+   if ((bind & PIPE_BIND_LINEAR) && rsc->layout != ETNA_LAYOUT_LINEAR)
+      return false;
+
+   if ((bind & PIPE_BIND_SCANOUT) && !rsc->scanout) {
+      rsc->scanout = renderonly_create_gpu_import_for_resource(prsc, 
screen->ro,
+                                                               NULL);
+      if (!rsc->scanout)
+         return false;
+   }
+
+   return true;
+}
+
 void
 etna_resource_used(struct etna_context *ctx, struct pipe_resource *prsc,
                    enum etna_resource_status status)
@@ -667,4 +688,5 @@ etna_resource_screen_init(struct pipe_screen *pscreen)
    pscreen->resource_get_handle = etna_resource_get_handle;
    pscreen->resource_changed = etna_resource_changed;
    pscreen->resource_destroy = etna_resource_destroy;
+   pscreen->check_resource_capability = etna_check_resource_capability;
 }
-- 
2.19.1

_______________________________________________
mesa-dev mailing list
mesa-dev@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/mesa-dev

Reply via email to