[Mesa-dev] [PATCH 02/27] mesa: add support for memory object creation/import/delete

Constantine Kharlamov Hi-Angel at yandex.ru
Wed Jul 19 20:52:02 UTC 2017


On 13.07.2017 01:45, Andres Rodriguez wrote:
> Used by EXT_external_objects and EXT_external_objects_fd
> 
> Signed-off-by: Andres Rodriguez <andresx7 at gmail.com>
> ---
>  src/mesa/drivers/common/driverfuncs.c |   4 +
>  src/mesa/main/dd.h                    |  36 +++++++++
>  src/mesa/main/externalobjects.c       | 145 +++++++++++++++++++++++++++++++++-
>  src/mesa/main/externalobjects.h       |  28 +++++++
>  src/mesa/main/mtypes.h                |   9 +++
>  src/mesa/main/shared.c                |  15 ++++
>  6 files changed, 234 insertions(+), 3 deletions(-)
> 
> diff --git a/src/mesa/drivers/common/driverfuncs.c b/src/mesa/drivers/common/driverfuncs.c
> index 5008ae8..ddb4bb6 100644
> --- a/src/mesa/drivers/common/driverfuncs.c
> +++ b/src/mesa/drivers/common/driverfuncs.c
> @@ -49,6 +49,7 @@
>  #include "main/syncobj.h"
>  #include "main/barrier.h"
>  #include "main/transformfeedback.h"
> +#include "main/externalobjects.h"
>  
>  #include "program/program.h"
>  #include "tnl/tnl.h"
> @@ -166,6 +167,9 @@ _mesa_init_driver_functions(struct dd_function_table *driver)
>  
>     _mesa_init_sync_object_functions(driver);
>  
> +   /* memory objects */
> +   _mesa_init_memory_object_functions(driver);
> +
>     driver->NewFramebuffer = _mesa_new_framebuffer;
>     driver->NewRenderbuffer = _swrast_new_soft_renderbuffer;
>     driver->MapRenderbuffer = _swrast_map_soft_renderbuffer;
> diff --git a/src/mesa/main/dd.h b/src/mesa/main/dd.h
> index 8e382e1..97ef5b8 100644
> --- a/src/mesa/main/dd.h
> +++ b/src/mesa/main/dd.h
> @@ -1069,6 +1069,42 @@ struct dd_function_table {
>     void (*MakeImageHandleResident)(struct gl_context *ctx, GLuint64 handle,
>                                     GLenum access, bool resident);
>     /*@}*/
> +
> +
> +   /**
> +    * \name GL_EXT_external_objects interface
> +    */
> +   /*@{*/
> +  /**
> +    * Called to allocate a new memory object.  Drivers will usually
> +    * allocate/return a subclass of gl_memory_object.
> +    */
> +   struct gl_memory_object * (*NewMemoryObject)(struct gl_context *ctx,
> +                                                GLuint name);
> +   /**
> +    * Called to delete/free a memory object.  Drivers should free the
> +    * object and any image data it contains.
> +    */
> +   void (*DeleteMemoryObject)(struct gl_context *ctx,
> +                              struct gl_memory_object *mem_obj);
> +   /*@}*/
> +
> +   /**
> +    * \name GL_EXT_external_objects_fd interface
> +    */
> +   /*@{*/
> +   /**
> +    * Called to import a memory object. The caller relinquishes ownership
> +    * of fd after the call returns.
> +    *
> +    * Accessing fd after ImportMemoryObjectFd returns results in undefined
> +    * behaviour. This is consistent with EXT_external_object_fd.
> +    */
> +   void (*ImportMemoryObjectFd)(struct gl_context *ctx,
> +                                struct gl_memory_object *mem_obj,
> +                                GLuint64 size,
> +                                int fd);
> +   /*@}*/
>  };
>  
>  
> diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c
> index d6c5109..2ae3f0b 100644
> --- a/src/mesa/main/externalobjects.c
> +++ b/src/mesa/main/externalobjects.c
> @@ -21,24 +21,145 @@
>   * DEALINGS IN THE SOFTWARE.
>   */
>  
> +#include "macros.h"
> +#include "mtypes.h"
>  #include "externalobjects.h"
>  
> +/**
> + * Allocate and initialize a new memory object.  But don't put it into the
> + * memory object hash table.
> + *
> + * Called via ctx->Driver.NewMemoryObject, unless overridden by a device
> + * driver.
> + *
> + * \return pointer to new memory object.
> + */
> +static struct gl_memory_object *
> +_mesa_new_memory_object(struct gl_context *ctx, GLuint name)
> +{
> +   struct gl_memory_object *obj;
> +   (void) ctx;

This line can be dropped — ctx is used 2 lines below.

> +   obj = MALLOC_STRUCT(gl_memory_object);
> +
> +   _mesa_initialize_memory_object(ctx, obj, name);
> +   return obj;
> +}


More information about the mesa-dev mailing list