Re: [Mesa-dev] [PATCH 03/24] mesa: add support for memory object parameters
On 07/27/2017 03:08 PM, Timothy Arceri wrote: From: Andres RodriguezV2 (Timothy Arceri): - fix copy and paste error with error message V3 (Timothy Arceri): - drop the Protected field for now as its unused Signed-off-by: Andres Rodriguez Reviewed-by: Timothy Arceri --- src/mesa/main/externalobjects.c | 51 - src/mesa/main/mtypes.h | 4 +++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c index 4cbada3f4e..c3ee0d8115 100644 --- a/src/mesa/main/externalobjects.c +++ b/src/mesa/main/externalobjects.c @@ -66,20 +66,21 @@ _mesa_init_memory_object_functions(struct dd_function_table *driver) /** * Initialize a buffer object to default values. */ void _mesa_initialize_memory_object(struct gl_context *ctx, struct gl_memory_object *obj, GLuint name) { memset(obj, 0, sizeof(struct gl_memory_object)); obj->Name = name; + obj->Dedicated = GL_FALSE; } void GLAPIENTRY _mesa_DeleteMemoryObjectsEXT(GLsizei n, const GLuint *memoryObjects) { GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & (VERBOSE_API)) _mesa_debug(ctx, "glDeleteMemoryObjectsEXT(%d, %p)\n", n, memoryObjects); @@ -135,21 +136,20 @@ _mesa_CreateMemoryObjectsEXT(GLsizei n, GLuint *memoryObjects) } if (!memoryObjects) return; _mesa_HashLockMutex(ctx->Shared->MemoryObjects); GLuint first = _mesa_HashFindFreeKeyBlock(ctx->Shared->MemoryObjects, n); if (first) { for (GLsizei i = 0; i < n; i++) { struct gl_memory_object *memObj; - mmh? memoryObjects[i] = first + i; /* allocate memory object */ memObj = ctx->Driver.NewMemoryObject(ctx, memoryObjects[i]); if (!memObj) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s()", func); goto out_unlock; } /* insert into hash table */ @@ -161,29 +161,77 @@ _mesa_CreateMemoryObjectsEXT(GLsizei n, GLuint *memoryObjects) out_unlock: _mesa_HashUnlockMutex(ctx->Shared->MemoryObjects); } void GLAPIENTRY _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); Like I said previously, if memoryObject is 0 this will crash (or assert). Does the spec allow memoryObject to be 0? Though, usually when an object is not found, we have to return GL_INVALID_OPERATION, but the spec doesn't seem to mention anything about that. + 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 _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 _mesa_TexStorageMem2DEXT(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset) @@ -375,19 +423,20 @@ _mesa_ImportMemoryFdEXT(GLuint memory, } if (memory == 0) return; struct gl_memory_object *memObj = _mesa_lookup_memory_object(ctx, memory); if (!memObj) return; ctx->Driver.ImportMemoryObjectFd(ctx, memObj, size, fd); + memObj->Immutable = GL_TRUE; }
[Mesa-dev] [PATCH 03/24] mesa: add support for memory object parameters
From: Andres RodriguezV2 (Timothy Arceri): - fix copy and paste error with error message V3 (Timothy Arceri): - drop the Protected field for now as its unused Signed-off-by: Andres Rodriguez Reviewed-by: Timothy Arceri --- src/mesa/main/externalobjects.c | 51 - src/mesa/main/mtypes.h | 4 +++- 2 files changed, 53 insertions(+), 2 deletions(-) diff --git a/src/mesa/main/externalobjects.c b/src/mesa/main/externalobjects.c index 4cbada3f4e..c3ee0d8115 100644 --- a/src/mesa/main/externalobjects.c +++ b/src/mesa/main/externalobjects.c @@ -66,20 +66,21 @@ _mesa_init_memory_object_functions(struct dd_function_table *driver) /** * Initialize a buffer object to default values. */ void _mesa_initialize_memory_object(struct gl_context *ctx, struct gl_memory_object *obj, GLuint name) { memset(obj, 0, sizeof(struct gl_memory_object)); obj->Name = name; + obj->Dedicated = GL_FALSE; } void GLAPIENTRY _mesa_DeleteMemoryObjectsEXT(GLsizei n, const GLuint *memoryObjects) { GET_CURRENT_CONTEXT(ctx); if (MESA_VERBOSE & (VERBOSE_API)) _mesa_debug(ctx, "glDeleteMemoryObjectsEXT(%d, %p)\n", n, memoryObjects); @@ -135,21 +136,20 @@ _mesa_CreateMemoryObjectsEXT(GLsizei n, GLuint *memoryObjects) } if (!memoryObjects) return; _mesa_HashLockMutex(ctx->Shared->MemoryObjects); GLuint first = _mesa_HashFindFreeKeyBlock(ctx->Shared->MemoryObjects, n); if (first) { for (GLsizei i = 0; i < n; i++) { struct gl_memory_object *memObj; - memoryObjects[i] = first + i; /* allocate memory object */ memObj = ctx->Driver.NewMemoryObject(ctx, memoryObjects[i]); if (!memObj) { _mesa_error(ctx, GL_OUT_OF_MEMORY, "%s()", func); goto out_unlock; } /* insert into hash table */ @@ -161,29 +161,77 @@ _mesa_CreateMemoryObjectsEXT(GLsizei n, GLuint *memoryObjects) out_unlock: _mesa_HashUnlockMutex(ctx->Shared->MemoryObjects); } void GLAPIENTRY _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 _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 _mesa_TexStorageMem2DEXT(GLenum target, GLsizei levels, GLenum internalFormat, GLsizei width, GLsizei height, GLuint memory, GLuint64 offset) @@ -375,19 +423,20 @@ _mesa_ImportMemoryFdEXT(GLuint memory, } if (memory == 0) return; struct gl_memory_object *memObj = _mesa_lookup_memory_object(ctx, memory); if (!memObj) return; ctx->Driver.ImportMemoryObjectFd(ctx, memObj, size, fd); + memObj->Immutable = GL_TRUE; } void GLAPIENTRY _mesa_ImportSemaphoreFdEXT(GLuint semaphore, GLenum handleType, GLint fd) { } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 642cd72d29..8cb9ae3d17 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -4640,21 +4640,23 @@ struct gl_texture_handle_object }; struct gl_image_handle_object { struct
Re: [Mesa-dev] [PATCH 03/24] mesa: add support for memory object parameters
On 27/07/17 00:39, Samuel Pitoiset wrote: On 07/26/2017 01:46 PM, Timothy Arceri wrote: From: Andres RodriguezV2 (Timothy Arceri): - fix copy and paste error with error message Signed-off-by: Andres Rodriguez Reviewed-by: Timothy Arceri --- 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). Dropped. } 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 */ }; /** ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
Re: [Mesa-dev] [PATCH 03/24] mesa: add support for memory object parameters
On 07/26/2017 01:46 PM, Timothy Arceri wrote: From: Andres RodriguezV2 (Timothy Arceri): - fix copy and paste error with error message Signed-off-by: Andres Rodriguez Reviewed-by: Timothy Arceri --- 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 */ }; /** ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev
[Mesa-dev] [PATCH 03/24] mesa: add support for memory object parameters
From: Andres RodriguezV2 (Timothy Arceri): - fix copy and paste error with error message Signed-off-by: Andres Rodriguez Reviewed-by: Timothy Arceri --- 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; } 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 */ }; /** -- 2.9.4 ___ mesa-dev mailing list mesa-dev@lists.freedesktop.org https://lists.freedesktop.org/mailman/listinfo/mesa-dev