summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDave Airlie <airlied@redhat.com>2020-06-19 16:24:48 +1000
committerDave Airlie <airlied@redhat.com>2020-07-27 13:11:58 +1000
commit6c456106599eb47a0eafabcfba14e11a1069237d (patch)
treed2e4f36b2bcdc94ddcf884d36a2902d4becb65f6
parentd46e0991055303e56dc023336fb99ee2c750684d (diff)
gallium: add an interface for memory allocations.
This to allow vulkan style memory allocation and binding for sw drivers.
-rw-r--r--src/gallium/include/pipe/p_screen.h41
-rw-r--r--src/gallium/include/pipe/p_state.h4
2 files changed, 45 insertions, 0 deletions
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.