diff options
Diffstat (limited to 'src/mesa/main/shared.c')
-rw-r--r-- | src/mesa/main/shared.c | 31 |
1 files changed, 29 insertions, 2 deletions
diff --git a/src/mesa/main/shared.c b/src/mesa/main/shared.c index 4d01e8abc6e..6cf63f64210 100644 --- a/src/mesa/main/shared.c +++ b/src/mesa/main/shared.c @@ -288,8 +288,8 @@ delete_renderbuffer_cb(GLuint id, void *data, void *userData) * * \sa alloc_shared_state(). */ -void -_mesa_free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) +static void +free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) { GLuint i; @@ -368,3 +368,30 @@ _mesa_free_shared_state(GLcontext *ctx, struct gl_shared_state *shared) _mesa_free(shared); } + + +/** + * Decrement shared state object reference count and potentially free it + * and all children structures. + * + * \param ctx GL context. + * \param shared shared state pointer. + * + * \sa free_shared_state(). + */ +void +_mesa_release_shared_state(GLcontext *ctx, struct gl_shared_state *shared) +{ + GLint RefCount; + + _glthread_LOCK_MUTEX(shared->Mutex); + RefCount = --shared->RefCount; + _glthread_UNLOCK_MUTEX(shared->Mutex); + + assert(RefCount >= 0); + + if (RefCount == 0) { + /* free shared state */ + free_shared_state( ctx, shared ); + } +} |