From: Dave Airlie Date: Fri, 19 Jun 2020 06:24:48 +0000 (+1000) Subject: gallium: add an interface for memory allocations. X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=e6c7ca218d77e5369d40d76941e7267d81633dc6;p=mesa.git 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 Reviewed-by: Marek Olšák Part-of: --- 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.