Mesa (master): gallium: add an interface for memory allocations.

GitLab Mirror gitlab-mirror at kemper.freedesktop.org
Mon Aug 17 05:01:07 UTC 2020


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

Author: Dave Airlie <airlied at redhat.com>
Date:   Fri Jun 19 16:24:48 2020 +1000

gallium: add an interface for memory allocations.

In order to support vulkan over gallium for the sw renderers,
there needs to be a vulkan-like memory allocation API.

It doesn't need to be overly complicated for the needs of the sw
renderers.

The vallium layer will allocate resources and memory separately
and bind them via this API.

Reviewed-by: Roland Scheidegger <sroland at vmware.com>
Reviewed-by: Marek Olšák <marek.olsak at amd.com>
Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/6082>

---

 src/gallium/include/pipe/p_screen.h | 41 +++++++++++++++++++++++++++++++++++++
 src/gallium/include/pipe/p_state.h  |  4 ++++
 2 files changed, 45 insertions(+)

diff --git a/src/gallium/include/pipe/p_screen.h b/src/gallium/include/pipe/p_screen.h
index a4b07c8ee25..3002689aeed 100644
--- a/src/gallium/include/pipe/p_screen.h
+++ b/src/gallium/include/pipe/p_screen.h
@@ -511,6 +511,47 @@ struct pipe_screen {
     *                  should be.
     */
    void (*finalize_nir)(struct pipe_screen *screen, void *nir, bool optimize);
+
+   /*Separated memory/resource allocations interfaces for Vulkan */
+
+   /**
+    * Create a resource, and retrieve the required size for it but don't allocate
+    * any backing memory.
+    */
+   struct pipe_resource * (*resource_create_unbacked)(struct pipe_screen *,
+                                                      const struct pipe_resource *templat,
+                                                      uint64_t *size_required);
+
+   /**
+    * Allocate backing memory to be bound to resources.
+    */
+   struct pipe_memory_allocation *(*allocate_memory)(struct pipe_screen *screen,
+                                                     uint64_t size);
+   /**
+    * Free previously allocated backing memory.
+    */
+   void (*free_memory)(struct pipe_screen *screen,
+                       struct pipe_memory_allocation *);
+
+   /**
+    * Bind memory to a resource.
+    */
+   void (*resource_bind_backing)(struct pipe_screen *screen,
+                                 struct pipe_resource *pt,
+                                 struct pipe_memory_allocation *pmem,
+                                 uint64_t offset);
+
+   /**
+    * Map backing memory.
+    */
+   void *(*map_memory)(struct pipe_screen *screen,
+                       struct pipe_memory_allocation *pmem);
+
+   /**
+    * Unmap backing memory.
+    */
+   void (*unmap_memory)(struct pipe_screen *screen,
+                        struct pipe_memory_allocation *pmem);
 };
 
 
diff --git a/src/gallium/include/pipe/p_state.h b/src/gallium/include/pipe/p_state.h
index 6f1d4c6309c..f38cb411dbb 100644
--- a/src/gallium/include/pipe/p_state.h
+++ b/src/gallium/include/pipe/p_state.h
@@ -574,6 +574,10 @@ struct pipe_resource
    struct pipe_screen *screen; /**< screen that this texture belongs to */
 };
 
+/**
+ * Opaque object used for separate resource/memory allocations.
+ */
+struct pipe_memory_allocation;
 
 /**
  * Transfer object.  For data transfer to/from a resource.



More information about the mesa-commit mailing list