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().
This commit is contained in:
Michel Dänzer
2009-03-04 11:58:48 +01:00
parent 60041203d5
commit 5e27cd46c0
102 changed files with 653 additions and 943 deletions

View File

@@ -74,11 +74,10 @@ st_bufferobj_alloc(GLcontext *ctx, GLuint name, GLenum target)
static void
st_bufferobj_free(GLcontext *ctx, struct gl_buffer_object *obj)
{
struct pipe_context *pipe = st_context(ctx)->pipe;
struct st_buffer_object *st_obj = st_buffer_object(obj);
if (st_obj->buffer)
pipe_buffer_reference(pipe->screen, &st_obj->buffer, NULL);
pipe_buffer_reference(&st_obj->buffer, NULL);
_mesa_free(st_obj);
}
@@ -165,7 +164,7 @@ st_bufferobj_data(GLcontext *ctx,
buffer_usage = 0;
}
pipe_buffer_reference( pipe->screen, &st_obj->buffer, NULL );
pipe_buffer_reference( &st_obj->buffer, NULL );
st_obj->buffer = pipe_buffer_create( pipe->screen, 32, buffer_usage, size );