From 5e27cd46c04a9e7b5904cc014bffd0f4daae31fe Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Wed, 4 Mar 2009 11:58:48 +0100 Subject: gallium: Unify reference counting. The core reference counting code is centralized in p_refcnt.h. This has some consequences related to struct pipe_buffer: * The screen member of struct pipe_buffer must be initialized, or pipe_buffer_reference() will crash trying to destroy a buffer with reference count 0. u_simple_screen takes care of this, but I may have missed some of the drivers not using it. * Except for rare exceptions deep in winsys code, buffers must always be allocated via pipe_buffer_create() or via screen->*buffer_create() rather than via winsys->*buffer_create(). --- src/gallium/include/pipe/p_inlines.h | 113 ----------------------------------- 1 file changed, 113 deletions(-) (limited to 'src/gallium/include/pipe/p_inlines.h') diff --git a/src/gallium/include/pipe/p_inlines.h b/src/gallium/include/pipe/p_inlines.h index 4eb928d882..a68b521429 100644 --- a/src/gallium/include/pipe/p_inlines.h +++ b/src/gallium/include/pipe/p_inlines.h @@ -38,97 +38,6 @@ extern "C" { #endif -/** - * Set 'ptr' to point to 'surf' and update reference counting. - * The old thing pointed to, if any, will be unreferenced first. - * 'surf' may be NULL. - */ -static INLINE void -pipe_surface_reference(struct pipe_surface **ptr, struct pipe_surface *surf) -{ - /* bump the refcount first */ - if (surf) { - assert(surf->refcount); - surf->refcount++; - } - - if (*ptr) { - struct pipe_screen *screen; - assert((*ptr)->refcount); - assert((*ptr)->texture); - screen = (*ptr)->texture->screen; - screen->tex_surface_release( screen, ptr ); - assert(!*ptr); - } - - *ptr = surf; -} - - -/** - * \sa pipe_surface_reference - */ -static INLINE void -pipe_transfer_reference(struct pipe_transfer **ptr, struct pipe_transfer *trans) -{ - /* bump the refcount first */ - if (trans) { - assert(trans->refcount); - trans->refcount++; - } - - if (*ptr) { - struct pipe_screen *screen; - assert((*ptr)->refcount); - assert((*ptr)->texture); - screen = (*ptr)->texture->screen; - screen->tex_transfer_release( screen, ptr ); - assert(!*ptr); - } - - *ptr = trans; -} - - -/** - * \sa pipe_surface_reference - */ -static INLINE void -pipe_texture_reference(struct pipe_texture **ptr, - struct pipe_texture *pt) -{ - assert(ptr); - - if (pt) { - assert(pt->refcount); - pt->refcount++; - } - - if (*ptr) { - struct pipe_screen *screen = (*ptr)->screen; - assert(screen); - assert((*ptr)->refcount); - screen->texture_release(screen, ptr); - - assert(!*ptr); - } - - *ptr = pt; -} - - -static INLINE void -pipe_texture_release(struct pipe_texture **ptr) -{ - struct pipe_screen *screen; - assert(ptr); - screen = (*ptr)->screen; - assert((*ptr)->refcount); - screen->texture_release(screen, ptr); - *ptr = NULL; -} - - /** * Convenience wrappers for screen buffer functions. */ @@ -199,28 +108,6 @@ pipe_buffer_read(struct pipe_screen *screen, } } -/* XXX: thread safety issues! - */ -static INLINE void -pipe_buffer_reference(struct pipe_screen *screen, - struct pipe_buffer **ptr, - struct pipe_buffer *buf) -{ - if (buf) { - assert(buf->refcount); - buf->refcount++; - } - - if (*ptr) { - assert((*ptr)->refcount); - if(--(*ptr)->refcount == 0) { - screen->buffer_destroy( screen, *ptr ); - } - } - - *ptr = buf; -} - #ifdef __cplusplus } -- cgit v1.2.3