diff options
author | Michel Dänzer <[email protected]> | 2009-03-04 11:58:48 +0100 |
---|---|---|
committer | Michel Dänzer <[email protected]> | 2009-03-04 11:58:48 +0100 |
commit | 5e27cd46c04a9e7b5904cc014bffd0f4daae31fe (patch) | |
tree | a57289f14d69f1977dfaee592af908052d726b8c /src/gallium/drivers/r300/r300_screen.c | |
parent | 60041203d5847de8ab71842a6ce5d33d96cc4930 (diff) |
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().
Diffstat (limited to 'src/gallium/drivers/r300/r300_screen.c')
-rw-r--r-- | src/gallium/drivers/r300/r300_screen.c | 16 |
1 files changed, 4 insertions, 12 deletions
diff --git a/src/gallium/drivers/r300/r300_screen.c b/src/gallium/drivers/r300/r300_screen.c index e97334463a3..3c91967a72e 100644 --- a/src/gallium/drivers/r300/r300_screen.c +++ b/src/gallium/drivers/r300/r300_screen.c @@ -268,7 +268,6 @@ r300_get_tex_transfer(struct pipe_screen *screen, trans = CALLOC_STRUCT(r300_transfer); if (trans) { - trans->transfer.refcount = 1; pipe_texture_reference(&trans->transfer.texture, texture); trans->transfer.format = trans->transfer.format; trans->transfer.width = w; @@ -284,17 +283,10 @@ r300_get_tex_transfer(struct pipe_screen *screen, } static void -r300_tex_transfer_release(struct pipe_screen *screen, - struct pipe_transfer **transfer) +r300_tex_transfer_destroy(struct pipe_transfer *trans) { - struct pipe_transfer *trans = *transfer; - - if (--trans->refcount == 0) { - pipe_texture_reference(&trans->texture, NULL); - FREE(trans); - } - - *transfer = NULL; + pipe_texture_reference(&trans->texture, NULL); + FREE(trans); } static void* r300_transfer_map(struct pipe_screen* screen, @@ -359,7 +351,7 @@ struct pipe_screen* r300_create_screen(struct r300_winsys* r300_winsys) r300screen->screen.get_paramf = r300_get_paramf; r300screen->screen.is_format_supported = r300_is_format_supported; r300screen->screen.get_tex_transfer = r300_get_tex_transfer; - r300screen->screen.tex_transfer_release = r300_tex_transfer_release; + r300screen->screen.tex_transfer_destroy = r300_tex_transfer_destroy; r300screen->screen.transfer_map = r300_transfer_map; r300screen->screen.transfer_unmap = r300_transfer_unmap; |