From f37070bab6af350caec905ea7658e9241042b6cc Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Fri, 28 Aug 2009 20:10:05 -0700 Subject: ARB sync: Add support for GL_ARB_sync to swrast This isn't quite right yet. The delete behavior and the context clean-up needs some work. --- src/mesa/main/syncobj.c | 372 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 372 insertions(+) create mode 100644 src/mesa/main/syncobj.c (limited to 'src/mesa/main/syncobj.c') diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c new file mode 100644 index 0000000000..eeeeb49175 --- /dev/null +++ b/src/mesa/main/syncobj.c @@ -0,0 +1,372 @@ +/* + * Copyright © 2009 Intel Corporation + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice (including the next + * paragraph) shall be included in all copies or substantial portions of the + * Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR + * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER + * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING + * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER + * DEALINGS IN THE SOFTWARE. + */ + +/** + * \file syncobj.c + * Sync object management. + * + * \author Ian Romanick + */ + +#include "glheader.h" +#include "hash.h" +#include "imports.h" +#include "context.h" + +#if FEATURE_ARB_sync +#include "syncobj.h" + +static struct gl_sync_object * +_mesa_new_sync_object(GLcontext *ctx, GLenum type) +{ + struct gl_sync_object *s = MALLOC_STRUCT(gl_sync_object); + (void) ctx; + (void) type; + + return s; +} + + +static void +_mesa_delete_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) +{ + (void) ctx; + _mesa_free(syncObj); +} + + +static void +_mesa_fence_sync(GLcontext *ctx, struct gl_sync_object *syncObj, + GLenum condition, GLbitfield flags) +{ + (void) ctx; + (void) condition; + (void) flags; + + syncObj->Status = 1; +} + + +static void +_mesa_check_sync(GLcontext *ctx, struct gl_sync_object *syncObj) +{ + (void) ctx; + (void) syncObj; + + /* No-op for software rendering. Hardware drivers will need to determine + * whether the state of the sync object has changed. + */ +} + + +static void +_mesa_wait_sync(GLcontext *ctx, struct gl_sync_object *syncObj, + GLbitfield flags, GLuint64 timeout) +{ + (void) ctx; + (void) syncObj; + (void) flags; + (void) timeout; + + + /* No-op for software rendering. Hardware drivers will need to wait until + * the state of the sync object changes or the timeout expires. + */ +} + + +void +_mesa_init_sync_object_functions(struct dd_function_table *driver) +{ + driver->NewSyncObject = _mesa_new_sync_object; + driver->FenceSync = _mesa_fence_sync; + driver->DeleteSyncObject = _mesa_delete_sync_object; + driver->CheckSync = _mesa_check_sync; + + /* Use the same no-op wait function for both. + */ + driver->ClientWaitSync = _mesa_wait_sync; + driver->ServerWaitSync = _mesa_wait_sync; +} + + +/** + * Allocate/init the context state related to sync objects. + */ +void +_mesa_init_sync(GLcontext *ctx) +{ + (void) ctx; +} + + +/** + * Free the context state related to sync objects. + */ +void +_mesa_free_sync_data(GLcontext *ctx) +{ + (void) ctx; +} + + +GLboolean +_mesa_IsSync(GLsync sync) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + + return ((syncObj != NULL) && (syncObj->Type == GL_SYNC_FENCE)) + ? GL_TRUE : GL_FALSE; +} + + +static void +_mesa_unref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) +{ + syncObj->RefCount--; + if (syncObj->RefCount == 0) { + (*ctx->Driver.DeleteSyncObject)(ctx, syncObj); + } else { + syncObj->DeletePending = 1; + } +} + + +void +_mesa_DeleteSync(GLsync sync) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + + /* From the GL_ARB_sync spec: + * + * DeleteSync will silently ignore a value of zero. An + * INVALID_VALUE error is generated if is neither zero nor the + * name of a sync object. + */ + if (sync == 0) { + return; + } + + if (syncObj->Type != GL_SYNC_FENCE) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteSync"); + return; + } + + + /* If there are no client-waits or server-waits pending on this sync, delete + * the underlying object. + */ + _mesa_unref_sync_object(ctx, syncObj); +} + + + +GLsync +_mesa_FenceSync(GLenum condition, GLbitfield flags) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *syncObj; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); + + + if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) { + _mesa_error(ctx, GL_INVALID_ENUM, "glFenceSync(condition=0x%x)", + condition); + return 0; + } + + if (flags != 0) { + _mesa_error(ctx, GL_INVALID_VALUE, "glFenceSync(flags=0x%x)", + condition); + return 0; + } + + syncObj = (*ctx->Driver.NewSyncObject)(ctx, GL_SYNC_FENCE); + if (syncObj != NULL) { + syncObj->Type = GL_SYNC_FENCE; + /* The name is not currently used, and it is never visible to + * applications. If sync support is extended to provide support for + * NV_fence, this field will be used. We'll also need to add an object + * ID hashtable. + */ + syncObj->Name = 1; + syncObj->RefCount = 1; + syncObj->DeletePending = GL_FALSE; + syncObj->SyncCondition = condition; + syncObj->Flags = flags; + syncObj->Status = 0; + + (*ctx->Driver.FenceSync)(ctx, syncObj, condition, flags); + + return (GLsync) syncObj; + } + + return NULL; +} + + +GLenum +_mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + GLenum ret; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_WAIT_FAILED); + + + if ((syncObj == NULL) || (syncObj->Type != GL_SYNC_FENCE)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glClientWaitSync"); + return GL_WAIT_FAILED; + } + + if ((flags & ~GL_SYNC_FLUSH_COMMANDS_BIT) != 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glClientWaitSync(flags=0x%x)", flags); + return GL_WAIT_FAILED; + } + + + /* From the GL_ARB_sync spec: + * + * ClientWaitSync returns one of four status values. A return value of + * ALREADY_SIGNALED indicates that was signaled at the time + * ClientWaitSync was called. ALREADY_SIGNALED will always be returned + * if was signaled, even if the value of is zero. + */ + (*ctx->Driver.CheckSync)(ctx, syncObj); + + if (syncObj->Status) { + return GL_ALREADY_SIGNALED; + } + + + (*ctx->Driver.ClientWaitSync)(ctx, syncObj, flags, timeout); + + ret = syncObj->Status ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED; + + if (syncObj->DeletePending && syncObj->Status) { + _mesa_unref_sync_object(ctx, syncObj); + } + + return ret; +} + + +void +_mesa_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + + if ((syncObj == NULL) || (syncObj->Type != GL_SYNC_FENCE)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glWaitSync"); + return; + } + + if (flags != 0) { + _mesa_error(ctx, GL_INVALID_ENUM, "glWaitSync(flags=0x%x)", flags); + return; + } + + /* From the GL_ARB_sync spec: + * + * If the value of is zero, then WaitSync does nothing. + */ + if (timeout == 0) { + return; + } + + (*ctx->Driver.ServerWaitSync)(ctx, syncObj, flags, timeout); +} + + +void +_mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, + GLint *values) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + GLsizei size = 0; + GLint v[1]; + ASSERT_OUTSIDE_BEGIN_END(ctx); + + + if ((syncObj == NULL) || (syncObj->Type != GL_SYNC_FENCE)) { + _mesa_error(ctx, GL_INVALID_OPERATION, "glGetSynciv"); + return; + } + + + switch (pname) { + case GL_OBJECT_TYPE: + v[0] = syncObj->Type; + size = 1; + break; + + case GL_SYNC_CONDITION: + v[0] = syncObj->SyncCondition; + size = 1; + break; + + case GL_SYNC_STATUS: + /* Update the state of the sync by dipping into the driver. Note that + * this call won't block. It just updates state in the common object + * data from the current driver state. + */ + (*ctx->Driver.CheckSync)(ctx, syncObj); + + v[0] = (syncObj->Status) ? GL_SIGNALED : GL_UNSIGNALED; + size = 1; + break; + + case GL_SYNC_FLAGS: + v[0] = syncObj->Flags; + size = 1; + break; + + default: + _mesa_error(ctx, GL_INVALID_ENUM, "glGetSynciv(pname=0x%x)\n", pname); + return; + } + + + if (size > 0) { + const GLsizei copy_count = (size > bufSize) ? bufSize : size; + + _mesa_memcpy(values, v, sizeof(GLint) * copy_count); + } + + + if (length != NULL) { + *length = size; + } +} + +#endif /* FEATURE_ARB_sync */ -- cgit v1.2.3 From 16b393d05990b6e917e144f9de87d0103b4c3e6d Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Mon, 31 Aug 2009 14:57:50 -0700 Subject: ARB sync: Fix delete behavior and context destruction behavior I believe this resolves the outstanding issues WRT sync object deletetion. I have also added a large comment at the top of syncobj.c describing the expected memory management behavior. I'm still a little uncertain about the locking on ctx->Shared. --- src/mesa/main/mtypes.h | 6 ++++ src/mesa/main/shared.c | 19 +++++++++- src/mesa/main/syncobj.c | 96 +++++++++++++++++++++++++++++++++++++------------ src/mesa/main/syncobj.h | 6 ++++ 4 files changed, 103 insertions(+), 24 deletions(-) (limited to 'src/mesa/main/syncobj.c') diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index 58da5d15eb..bd3bf28328 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -40,6 +40,7 @@ #include "main/mfeatures.h" #include "glapi/glapi.h" #include "math/m_matrix.h" /* GLmatrix */ +#include "main/simple_list.h" /* struct simple_node */ /** @@ -1988,6 +1989,7 @@ struct gl_query_state /** Sync object state */ struct gl_sync_object { + struct simple_node link; GLenum Type; /**< GL_SYNC_FENCE */ GLuint Name; /**< Fence name */ GLint RefCount; /**< Reference count */ @@ -2145,6 +2147,10 @@ struct gl_shared_state struct _mesa_HashTable *FrameBuffers; #endif +#if FEATURE_ARB_sync + struct simple_node SyncObjects; +#endif + void *DriverData; /**< Device driver shared state */ }; diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index 93bbccd3c7..643ad3354e 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -43,7 +43,9 @@ #if FEATURE_ATI_fragment_shader #include "shader/atifragshader.h" #endif - +#if FEATURE_ARB_sync +#include "syncobj.h" +#endif /** * Allocate and initialize a shared context state structure. @@ -127,6 +129,10 @@ _mesa_alloc_shared_state(GLcontext *ctx) shared->RenderBuffers = _mesa_NewHashTable(); #endif +#if FEATURE_ARB_sync + make_empty_list(& shared->SyncObjects); +#endif + return shared; } @@ -336,6 +342,17 @@ _mesa_free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) ctx->Driver.DeleteBuffer(ctx, shared->NullBufferObj); #endif +#if FEATURE_ARB_sync + { + struct simple_node *node; + struct simple_node *temp; + + foreach_s(node, temp, & shared->SyncObjects) { + _mesa_unref_sync_object(ctx, (struct gl_sync_object *) node); + } + } +#endif + /* * Free texture objects (after FBOs since some textures might have * been bound to FBOs). diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index eeeeb49175..0471a0ad7f 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -25,6 +25,33 @@ * \file syncobj.c * Sync object management. * + * Unlike textures and other objects that are shared between contexts, sync + * objects are not bound to the context. As a result, the reference counting + * and delete behavior of sync objects is slightly different. References to + * sync objects are added: + * + * - By \c glFencSynce. This sets the initial reference count to 1. + * - At the start of \c glClientWaitSync. The reference is held for the + * duration of the wait call. + * + * References are removed: + * + * - By \c glDeleteSync. + * - At the end of \c glClientWaitSync. + * + * Additionally, drivers may call \c _mesa_ref_sync_object and + * \c _mesa_unref_sync_object as needed to implement \c ServerWaitSync. + * + * As with shader objects, sync object names become invalid as soon as + * \c glDeleteSync is called. For this reason \c glDeleteSync sets the + * \c DeletePending flag. All functions validate object handles by testing + * this flag. + * + * \note + * Only \c GL_ARB_sync objects are shared between contexts. If support is ever + * added for either \c GL_NV_fence or \c GL_APPLE_fence different semantics + * will need to be implemented. + * * \author Ian Romanick */ @@ -130,31 +157,52 @@ _mesa_free_sync_data(GLcontext *ctx) } -GLboolean -_mesa_IsSync(GLsync sync) +static int +_mesa_validate_sync(struct gl_sync_object *syncObj) { - GET_CURRENT_CONTEXT(ctx); - struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; - ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + return (syncObj != NULL) + && (syncObj->Type == GL_SYNC_FENCE) + && !syncObj->DeletePending; +} - return ((syncObj != NULL) && (syncObj->Type == GL_SYNC_FENCE)) - ? GL_TRUE : GL_FALSE; +void +_mesa_ref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) +{ + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + syncObj->RefCount++; + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); } -static void +void _mesa_unref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) { + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); syncObj->RefCount--; if (syncObj->RefCount == 0) { + remove_from_list(& syncObj->link); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + (*ctx->Driver.DeleteSyncObject)(ctx, syncObj); } else { - syncObj->DeletePending = 1; + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); } } +GLboolean +_mesa_IsSync(GLsync sync) +{ + GET_CURRENT_CONTEXT(ctx); + struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; + ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); + + + return _mesa_validate_sync(syncObj) ? GL_TRUE : GL_FALSE; +} + + void _mesa_DeleteSync(GLsync sync) { @@ -173,7 +221,7 @@ _mesa_DeleteSync(GLsync sync) return; } - if (syncObj->Type != GL_SYNC_FENCE) { + if (!_mesa_validate_sync(syncObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glDeleteSync"); return; } @@ -182,6 +230,7 @@ _mesa_DeleteSync(GLsync sync) /* If there are no client-waits or server-waits pending on this sync, delete * the underlying object. */ + syncObj->DeletePending = GL_TRUE; _mesa_unref_sync_object(ctx, syncObj); } @@ -224,6 +273,10 @@ _mesa_FenceSync(GLenum condition, GLbitfield flags) (*ctx->Driver.FenceSync)(ctx, syncObj, condition, flags); + _glthread_LOCK_MUTEX(ctx->Shared->Mutex); + insert_at_tail(& ctx->Shared->SyncObjects, & syncObj->link); + _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); + return (GLsync) syncObj; } @@ -240,7 +293,7 @@ _mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_WAIT_FAILED); - if ((syncObj == NULL) || (syncObj->Type != GL_SYNC_FENCE)) { + if (!_mesa_validate_sync(syncObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glClientWaitSync"); return GL_WAIT_FAILED; } @@ -251,6 +304,8 @@ _mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) } + _mesa_ref_sync_object(ctx, syncObj); + /* From the GL_ARB_sync spec: * * ClientWaitSync returns one of four status values. A return value of @@ -259,20 +314,15 @@ _mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) * if was signaled, even if the value of is zero. */ (*ctx->Driver.CheckSync)(ctx, syncObj); - if (syncObj->Status) { - return GL_ALREADY_SIGNALED; - } - - - (*ctx->Driver.ClientWaitSync)(ctx, syncObj, flags, timeout); - - ret = syncObj->Status ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED; + ret = GL_ALREADY_SIGNALED; + } else { + (*ctx->Driver.ClientWaitSync)(ctx, syncObj, flags, timeout); - if (syncObj->DeletePending && syncObj->Status) { - _mesa_unref_sync_object(ctx, syncObj); + ret = syncObj->Status ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED; } + _mesa_unref_sync_object(ctx, syncObj); return ret; } @@ -285,7 +335,7 @@ _mesa_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) ASSERT_OUTSIDE_BEGIN_END(ctx); - if ((syncObj == NULL) || (syncObj->Type != GL_SYNC_FENCE)) { + if (!_mesa_validate_sync(syncObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glWaitSync"); return; } @@ -318,7 +368,7 @@ _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, ASSERT_OUTSIDE_BEGIN_END(ctx); - if ((syncObj == NULL) || (syncObj->Type != GL_SYNC_FENCE)) { + if (!_mesa_validate_sync(syncObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetSynciv"); return; } diff --git a/src/mesa/main/syncobj.h b/src/mesa/main/syncobj.h index d2b4d051c9..fc160af289 100644 --- a/src/mesa/main/syncobj.h +++ b/src/mesa/main/syncobj.h @@ -42,6 +42,12 @@ _mesa_init_sync(GLcontext *); extern void _mesa_free_sync_data(GLcontext *); +extern void +_mesa_ref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj); + +extern void +_mesa_unref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj); + extern GLboolean _mesa_IsSync(GLsync sync); -- cgit v1.2.3 From 0f8fdd81989de5026c8e415f1525931b74dd8647 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 1 Sep 2009 11:24:54 -0700 Subject: Use MIN2 instead of open-coded version Based on review comments by Brian Paul. --- src/mesa/main/syncobj.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/mesa/main/syncobj.c') diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index 0471a0ad7f..cbeda4b384 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -59,6 +59,7 @@ #include "hash.h" #include "imports.h" #include "context.h" +#include "macros.h" #if FEATURE_ARB_sync #include "syncobj.h" @@ -408,7 +409,7 @@ _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, if (size > 0) { - const GLsizei copy_count = (size > bufSize) ? bufSize : size; + const GLsizei copy_count = MIN2(size, bufSize); _mesa_memcpy(values, v, sizeof(GLint) * copy_count); } -- cgit v1.2.3 From 6af24b6b03a2ce8300c7ae78fd06c6b1edd02017 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 1 Sep 2009 11:56:34 -0700 Subject: Whitespace and include file clean-up. Based on review comments by Brian Paul. --- src/mesa/main/syncobj.c | 14 -------------- 1 file changed, 14 deletions(-) (limited to 'src/mesa/main/syncobj.c') diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index cbeda4b384..b3c75c747a 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -56,7 +56,6 @@ */ #include "glheader.h" -#include "hash.h" #include "imports.h" #include "context.h" #include "macros.h" @@ -116,7 +115,6 @@ _mesa_wait_sync(GLcontext *ctx, struct gl_sync_object *syncObj, (void) flags; (void) timeout; - /* No-op for software rendering. Hardware drivers will need to wait until * the state of the sync object changes or the timeout expires. */ @@ -199,7 +197,6 @@ _mesa_IsSync(GLsync sync) struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_FALSE); - return _mesa_validate_sync(syncObj) ? GL_TRUE : GL_FALSE; } @@ -211,7 +208,6 @@ _mesa_DeleteSync(GLsync sync) struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; ASSERT_OUTSIDE_BEGIN_END(ctx); - /* From the GL_ARB_sync spec: * * DeleteSync will silently ignore a value of zero. An @@ -227,7 +223,6 @@ _mesa_DeleteSync(GLsync sync) return; } - /* If there are no client-waits or server-waits pending on this sync, delete * the underlying object. */ @@ -236,7 +231,6 @@ _mesa_DeleteSync(GLsync sync) } - GLsync _mesa_FenceSync(GLenum condition, GLbitfield flags) { @@ -244,7 +238,6 @@ _mesa_FenceSync(GLenum condition, GLbitfield flags) struct gl_sync_object *syncObj; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, 0); - if (condition != GL_SYNC_GPU_COMMANDS_COMPLETE) { _mesa_error(ctx, GL_INVALID_ENUM, "glFenceSync(condition=0x%x)", condition); @@ -293,7 +286,6 @@ _mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) GLenum ret; ASSERT_OUTSIDE_BEGIN_END_WITH_RETVAL(ctx, GL_WAIT_FAILED); - if (!_mesa_validate_sync(syncObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glClientWaitSync"); return GL_WAIT_FAILED; @@ -304,7 +296,6 @@ _mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) return GL_WAIT_FAILED; } - _mesa_ref_sync_object(ctx, syncObj); /* From the GL_ARB_sync spec: @@ -335,7 +326,6 @@ _mesa_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) struct gl_sync_object *const syncObj = (struct gl_sync_object *) sync; ASSERT_OUTSIDE_BEGIN_END(ctx); - if (!_mesa_validate_sync(syncObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glWaitSync"); return; @@ -368,13 +358,11 @@ _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, GLint v[1]; ASSERT_OUTSIDE_BEGIN_END(ctx); - if (!_mesa_validate_sync(syncObj)) { _mesa_error(ctx, GL_INVALID_OPERATION, "glGetSynciv"); return; } - switch (pname) { case GL_OBJECT_TYPE: v[0] = syncObj->Type; @@ -407,14 +395,12 @@ _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, return; } - if (size > 0) { const GLsizei copy_count = MIN2(size, bufSize); _mesa_memcpy(values, v, sizeof(GLint) * copy_count); } - if (length != NULL) { *length = size; } -- cgit v1.2.3 From 0342dce226fe79d7a6c0e7cd735c596fad3e8aac Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Tue, 1 Sep 2009 11:58:36 -0700 Subject: Don't dereference function pointers in calls. I'm apparently alone in prefering this calling convention, so I'll be a team player. :p Based on review comments by Brian Paul and Eric Anholt. --- src/mesa/main/syncobj.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'src/mesa/main/syncobj.c') diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index b3c75c747a..075931c7ce 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -183,7 +183,7 @@ _mesa_unref_sync_object(GLcontext *ctx, struct gl_sync_object *syncObj) remove_from_list(& syncObj->link); _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); - (*ctx->Driver.DeleteSyncObject)(ctx, syncObj); + ctx->Driver.DeleteSyncObject(ctx, syncObj); } else { _glthread_UNLOCK_MUTEX(ctx->Shared->Mutex); } @@ -250,7 +250,7 @@ _mesa_FenceSync(GLenum condition, GLbitfield flags) return 0; } - syncObj = (*ctx->Driver.NewSyncObject)(ctx, GL_SYNC_FENCE); + syncObj = ctx->Driver.NewSyncObject(ctx, GL_SYNC_FENCE); if (syncObj != NULL) { syncObj->Type = GL_SYNC_FENCE; /* The name is not currently used, and it is never visible to @@ -265,7 +265,7 @@ _mesa_FenceSync(GLenum condition, GLbitfield flags) syncObj->Flags = flags; syncObj->Status = 0; - (*ctx->Driver.FenceSync)(ctx, syncObj, condition, flags); + ctx->Driver.FenceSync(ctx, syncObj, condition, flags); _glthread_LOCK_MUTEX(ctx->Shared->Mutex); insert_at_tail(& ctx->Shared->SyncObjects, & syncObj->link); @@ -305,11 +305,11 @@ _mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) * ClientWaitSync was called. ALREADY_SIGNALED will always be returned * if was signaled, even if the value of is zero. */ - (*ctx->Driver.CheckSync)(ctx, syncObj); + ctx->Driver.CheckSync(ctx, syncObj); if (syncObj->Status) { ret = GL_ALREADY_SIGNALED; } else { - (*ctx->Driver.ClientWaitSync)(ctx, syncObj, flags, timeout); + ctx->Driver.ClientWaitSync(ctx, syncObj, flags, timeout); ret = syncObj->Status ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED; } @@ -344,7 +344,7 @@ _mesa_WaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) return; } - (*ctx->Driver.ServerWaitSync)(ctx, syncObj, flags, timeout); + ctx->Driver.ServerWaitSync(ctx, syncObj, flags, timeout); } @@ -379,7 +379,7 @@ _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, * this call won't block. It just updates state in the common object * data from the current driver state. */ - (*ctx->Driver.CheckSync)(ctx, syncObj); + ctx->Driver.CheckSync(ctx, syncObj); v[0] = (syncObj->Status) ? GL_SIGNALED : GL_UNSIGNALED; size = 1; -- cgit v1.2.3 From e059885ce357dee8b847f10e8e8c515a4a20042e Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Thu, 3 Sep 2009 12:47:25 -0600 Subject: mesa: rename gl_sync_object::Status to StatusFlag There's a symbol collision with X11/Xlib.h #define Status int in the Mesa xlib code. This seems the simpliest way to work around this. --- src/mesa/drivers/dri/intel/intel_syncobj.c | 4 ++-- src/mesa/main/mtypes.h | 2 +- src/mesa/main/syncobj.c | 10 +++++----- 3 files changed, 8 insertions(+), 8 deletions(-) (limited to 'src/mesa/main/syncobj.c') diff --git a/src/mesa/drivers/dri/intel/intel_syncobj.c b/src/mesa/drivers/dri/intel/intel_syncobj.c index d447b6a0fa..1286fe929b 100644 --- a/src/mesa/drivers/dri/intel/intel_syncobj.c +++ b/src/mesa/drivers/dri/intel/intel_syncobj.c @@ -94,7 +94,7 @@ static void intel_client_wait_sync(GLcontext *ctx, struct gl_sync_object *s, if (sync->bo) { drm_intel_bo_wait_rendering(sync->bo); - s->Status = 1; + s->StatusFlag = 1; drm_intel_bo_unreference(sync->bo); sync->bo = NULL; } @@ -117,7 +117,7 @@ static void intel_check_sync(GLcontext *ctx, struct gl_sync_object *s) if (sync->bo && drm_intel_bo_busy(sync->bo)) { drm_intel_bo_unreference(sync->bo); sync->bo = NULL; - s->Status = 1; + s->StatusFlag = 1; } } diff --git a/src/mesa/main/mtypes.h b/src/mesa/main/mtypes.h index bd3bf28328..6b64bf8139 100644 --- a/src/mesa/main/mtypes.h +++ b/src/mesa/main/mtypes.h @@ -1998,7 +1998,7 @@ struct gl_sync_object { */ GLenum SyncCondition; GLbitfield Flags; /**< Flags passed to glFenceSync */ - GLuint Status:1; /**< Has the sync object been signaled? */ + GLuint StatusFlag:1; /**< Has the sync object been signaled? */ }; diff --git a/src/mesa/main/syncobj.c b/src/mesa/main/syncobj.c index 075931c7ce..64f923ff91 100644 --- a/src/mesa/main/syncobj.c +++ b/src/mesa/main/syncobj.c @@ -90,7 +90,7 @@ _mesa_fence_sync(GLcontext *ctx, struct gl_sync_object *syncObj, (void) condition; (void) flags; - syncObj->Status = 1; + syncObj->StatusFlag = 1; } @@ -263,7 +263,7 @@ _mesa_FenceSync(GLenum condition, GLbitfield flags) syncObj->DeletePending = GL_FALSE; syncObj->SyncCondition = condition; syncObj->Flags = flags; - syncObj->Status = 0; + syncObj->StatusFlag = 0; ctx->Driver.FenceSync(ctx, syncObj, condition, flags); @@ -306,12 +306,12 @@ _mesa_ClientWaitSync(GLsync sync, GLbitfield flags, GLuint64 timeout) * if was signaled, even if the value of is zero. */ ctx->Driver.CheckSync(ctx, syncObj); - if (syncObj->Status) { + if (syncObj->StatusFlag) { ret = GL_ALREADY_SIGNALED; } else { ctx->Driver.ClientWaitSync(ctx, syncObj, flags, timeout); - ret = syncObj->Status ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED; + ret = syncObj->StatusFlag ? GL_CONDITION_SATISFIED : GL_TIMEOUT_EXPIRED; } _mesa_unref_sync_object(ctx, syncObj); @@ -381,7 +381,7 @@ _mesa_GetSynciv(GLsync sync, GLenum pname, GLsizei bufSize, GLsizei *length, */ ctx->Driver.CheckSync(ctx, syncObj); - v[0] = (syncObj->Status) ? GL_SIGNALED : GL_UNSIGNALED; + v[0] = (syncObj->StatusFlag) ? GL_SIGNALED : GL_UNSIGNALED; size = 1; break; -- cgit v1.2.3