Mesa (main): crocus: hook up resource creation from memory object

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Tue Jun 15 00:13:26 UTC 2021


Module: Mesa
Branch: main
Commit: bc9af971d259c2e753b5839d7f043f854907a6e2
URL:    http://cgit.freedesktop.org/mesa/mesa/commit/?id=bc9af971d259c2e753b5839d7f043f854907a6e2

Author: Dave Airlie <airlied at gmail.com>
Date:   Mon Jun 14 12:34:45 2021 +1000

crocus: hook up resource creation from memory object

Port 772dc50d162f6ac99676ef5134607f0d0e6db21e from iris

Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/11352>

---

 src/gallium/drivers/crocus/crocus_resource.c | 29 ++++++++++++++++++++++++++++
 src/gallium/drivers/crocus/crocus_resource.h |  2 ++
 2 files changed, 31 insertions(+)

diff --git a/src/gallium/drivers/crocus/crocus_resource.c b/src/gallium/drivers/crocus/crocus_resource.c
index f6f828c13ff..3d284c2544b 100644
--- a/src/gallium/drivers/crocus/crocus_resource.c
+++ b/src/gallium/drivers/crocus/crocus_resource.c
@@ -936,6 +936,32 @@ fail:
    return NULL;
 }
 
+static struct pipe_resource *
+crocus_resource_from_memobj(struct pipe_screen *pscreen,
+                            const struct pipe_resource *templ,
+                            struct pipe_memory_object *pmemobj,
+                            uint64_t offset)
+{
+   struct crocus_screen *screen = (struct crocus_screen *)pscreen;
+   struct crocus_memory_object *memobj = (struct crocus_memory_object *)pmemobj;
+   struct crocus_resource *res = crocus_alloc_resource(pscreen, templ);
+
+   if (!res)
+      return NULL;
+
+   if (templ->flags & PIPE_RESOURCE_FLAG_TEXTURING_MORE_LIKELY) {
+      UNUSED const bool isl_surf_created_successfully =
+         crocus_resource_configure_main(screen, res, templ, DRM_FORMAT_MOD_INVALID, 0);
+      assert(isl_surf_created_successfully);
+   }
+
+   res->bo = memobj->bo;
+   res->offset = offset;
+   res->external_format = memobj->format;
+
+   return &res->base;
+}
+
 static void
 crocus_flush_resource(struct pipe_context *ctx, struct pipe_resource *resource)
 {
@@ -1934,6 +1960,8 @@ crocus_memobj_create_from_handle(struct pipe_screen *pscreen,
 
    memobj->b.dedicated = dedicated;
    memobj->bo = bo;
+   memobj->format = whandle->format;
+   memobj->stride = whandle->stride;
 
    crocus_bo_reference(memobj->bo);
 
@@ -1962,6 +1990,7 @@ crocus_init_screen_resource_functions(struct pipe_screen *pscreen)
    pscreen->resource_create = u_transfer_helper_resource_create;
    pscreen->resource_from_user_memory = crocus_resource_from_user_memory;
    pscreen->resource_from_handle = crocus_resource_from_handle;
+   pscreen->resource_from_memobj = crocus_resource_from_memobj;
    pscreen->resource_get_handle = crocus_resource_get_handle;
    pscreen->resource_get_param = crocus_resource_get_param;
    pscreen->resource_destroy = u_transfer_helper_resource_destroy;
diff --git a/src/gallium/drivers/crocus/crocus_resource.h b/src/gallium/drivers/crocus/crocus_resource.h
index 86ccb25e79d..505bf0ad41e 100644
--- a/src/gallium/drivers/crocus/crocus_resource.h
+++ b/src/gallium/drivers/crocus/crocus_resource.h
@@ -288,6 +288,8 @@ struct crocus_transfer {
 struct crocus_memory_object {
    struct pipe_memory_object b;
    struct crocus_bo *bo;
+   uint64_t format;
+   unsigned stride;
 };
 
 /**



More information about the mesa-commit mailing list