[Mesa-dev] [PATCH 03/24] mesa: add support for memory object parameters

Samuel Pitoiset samuel.pitoiset at gmail.com
Wed Jul 26 14:39:58 UTC 2017



On 07/26/2017 01:46 PM, Timothy Arceri wrote:
> From: Andres Rodriguez <andresx7 at gmail.com>
> 
> V2 (Timothy Arceri):
>   - fix copy and paste error with error message
> 
> Signed-off-by: Andres Rodriguez <andresx7 at gmail.com>
> Reviewed-by: Timothy Arceri <tarceri at itsqueeze.com>
> ---
>   src/mesa/main/externalobjects.c | 52 ++++++++++++++++++++++++++++++++++++++++-
>   src/mesa/main/mtypes.h          |  5 +++-
>   2 files changed, 55 insertions(+), 2 deletions(-)
> 
> diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c
> index 01fb19a..e0063e8 100644
> --- a/src/mesa/main/externalobjects.c
> +++ b/src/mesa/main/externalobjects.c
> @@ -70,6 +70,8 @@ _mesa_initialize_memory_object(struct gl_context *ctx,
>   {
>      memset(obj, 0, sizeof(struct gl_memory_object));
>      obj->Name = name;
> +   obj->Dedicated = GL_FALSE;
> +   obj->Protected = GL_FALSE;

Why introducing the Protected field if it's not used? (at least not in 
this patch).

>   }
>   
>   void GLAPIENTRY
> @@ -139,7 +141,6 @@ _mesa_CreateMemoryObjectsEXT(GLsizei n, GLuint *memoryObjects)
>      if (first) {
>         for (GLsizei i = 0; i < n; i++) {
>            struct gl_memory_object *memObj;
> -
>            memoryObjects[i] = first + i;
>   
>            /* allocate memory object */
> @@ -165,7 +166,34 @@ _mesa_MemoryObjectParameterivEXT(GLuint memoryObject,
>                                    GLenum pname,
>                                    const GLint *params)
>   {
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_memory_object *memObj;
> +
> +   memObj = _mesa_lookup_memory_object(ctx, memoryObject);
> +   if (!memObj)
> +      return;
> +
> +   if (memObj->Immutable) {
> +      _mesa_error(ctx, GL_INVALID_OPERATION,
> +                  "glMemoryObjectParameterivEXT(memoryObject is immutable");
> +      return;
> +   }
>   
> +   switch (pname) {
> +   case GL_DEDICATED_MEMORY_OBJECT_EXT:
> +      memObj->Dedicated = (GLboolean) params[0];
> +      break;
> +   case GL_PROTECTED_MEMORY_OBJECT_EXT:
> +      /* EXT_protected_textures not supported */
> +      goto invalid_pname;
> +   default:
> +      goto invalid_pname;
> +   }
> +   return;
> +
> +invalid_pname:
> +   _mesa_error(ctx, GL_INVALID_ENUM,
> +               "glMemoryObjectParameterivEXT(pname=0x%x)", pname);
>   }
>   
>   void GLAPIENTRY
> @@ -173,7 +201,28 @@ _mesa_GetMemoryObjectParameterivEXT(GLuint memoryObject,
>                                       GLenum pname,
>                                       GLint *params)
>   {
> +   GET_CURRENT_CONTEXT(ctx);
> +   struct gl_memory_object *memObj;
> +
> +   memObj = _mesa_lookup_memory_object(ctx, memoryObject);
> +   if (!memObj)
> +      return;
> +
> +   switch (pname) {
> +      case GL_DEDICATED_MEMORY_OBJECT_EXT:
> +         *params = (GLint) memObj->Dedicated;
> +         break;
> +      case GL_PROTECTED_MEMORY_OBJECT_EXT:
> +         /* EXT_protected_textures not supported */
> +         goto invalid_pname;
> +      default:
> +         goto invalid_pname;
> +   }
> +   return;
>   
> +invalid_pname:
> +   _mesa_error(ctx, GL_INVALID_ENUM,
> +               "glGetMemoryObjectParameterivEXT(pname=0x%x)", pname);
>   }
>   
>   void GLAPIENTRY
> @@ -379,6 +428,7 @@ _mesa_ImportMemoryFdEXT(GLuint memory,
>         return;
>   
>      ctx->Driver.ImportMemoryObjectFd(ctx, memObj, size, fd);
> +   memObj->Immutable = GL_TRUE;
>   }
>   
>   void GLAPIENTRY
> diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h
> index 642cd72..356ec69 100644
> --- a/src/mesa/main/mtypes.h
> +++ b/src/mesa/main/mtypes.h
> @@ -4647,7 +4647,10 @@ struct gl_image_handle_object
>   
>   struct gl_memory_object
>   {
> -   GLuint Name;          /**< hash table ID/name */
> +   GLuint Name;            /**< hash table ID/name */
> +   GLboolean Immutable;    /**< denotes mutability state of parameters */
> +   GLboolean Dedicated;    /**< import memory from a dedicated allocation */
> +   GLboolean Protected;    /**< import memory from a protected allocation */
>   };
>   
>   /**
> 


More information about the mesa-dev mailing list