summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers/trace/tr_screen.c
diff options
context:
space:
mode:
authorMichel Dänzer <[email protected]>2009-03-04 11:58:48 +0100
committerMichel Dänzer <[email protected]>2009-03-04 11:58:48 +0100
commit5e27cd46c04a9e7b5904cc014bffd0f4daae31fe (patch)
treea57289f14d69f1977dfaee592af908052d726b8c /src/gallium/drivers/trace/tr_screen.c
parent60041203d5847de8ab71842a6ce5d33d96cc4930 (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/trace/tr_screen.c')
-rw-r--r--src/gallium/drivers/trace/tr_screen.c122
1 files changed, 33 insertions, 89 deletions
diff --git a/src/gallium/drivers/trace/tr_screen.c b/src/gallium/drivers/trace/tr_screen.c
index 164c6bbc4d6..1d868eff6bb 100644
--- a/src/gallium/drivers/trace/tr_screen.c
+++ b/src/gallium/drivers/trace/tr_screen.c
@@ -207,37 +207,18 @@ trace_screen_texture_blanket(struct pipe_screen *_screen,
static void
-trace_screen_texture_release(struct pipe_screen *_screen,
- struct pipe_texture **ptexture)
+trace_screen_texture_destroy(struct pipe_texture *texture)
{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct pipe_texture *texture;
-
- assert(ptexture);
- if(*ptexture) {
- tr_tex = trace_texture(tr_scr, *ptexture);
- texture = tr_tex->texture;
- assert(texture->screen == screen);
- }
- else
- texture = NULL;
-
- if (*ptexture) {
- if (!--(*ptexture)->refcount) {
- trace_dump_call_begin("pipe_screen", "texture_destroy");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(ptr, texture);
-
- trace_texture_destroy(tr_scr, *ptexture);
-
- trace_dump_call_end();
- }
+ struct pipe_screen *screen = texture->screen;
- *ptexture = NULL;
- }
+ trace_dump_call_begin("pipe_screen", "texture_destroy");
+
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, texture);
+
+ trace_texture_destroy(trace_screen(screen), texture);
+
+ trace_dump_call_end();
}
@@ -280,38 +261,19 @@ trace_screen_get_tex_surface(struct pipe_screen *_screen,
static void
-trace_screen_tex_surface_release(struct pipe_screen *_screen,
- struct pipe_surface **psurface)
+trace_screen_tex_surface_destroy(struct pipe_surface *surface)
{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct trace_surface *tr_surf;
- struct pipe_surface *surface;
-
- assert(psurface);
- if(*psurface) {
- tr_tex = trace_texture(tr_scr, (*psurface)->texture);
- tr_surf = trace_surface(tr_tex, *psurface);
- surface = tr_surf->surface;
- }
- else
- surface = NULL;
+ struct pipe_screen *screen = surface->texture->screen;
- if (*psurface) {
- if (!--(*psurface)->refcount) {
- trace_dump_call_begin("pipe_screen", "tex_surface_destroy");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(ptr, surface);
+ trace_dump_call_begin("pipe_screen", "tex_surface_destroy");
- trace_surface_destroy(tr_tex, *psurface);
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, surface);
- trace_dump_call_end();
- }
-
- *psurface = NULL;
- }
+ trace_surface_destroy(trace_texture(trace_screen(screen), surface->texture),
+ surface);
+
+ trace_dump_call_end();
}
@@ -356,38 +318,20 @@ trace_screen_get_tex_transfer(struct pipe_screen *_screen,
static void
-trace_screen_tex_transfer_release(struct pipe_screen *_screen,
- struct pipe_transfer **ptransfer)
+trace_screen_tex_transfer_destroy(struct pipe_transfer *transfer)
{
- struct trace_screen *tr_scr = trace_screen(_screen);
- struct pipe_screen *screen = tr_scr->screen;
- struct trace_texture *tr_tex;
- struct trace_transfer *tr_trans;
- struct pipe_transfer *transfer;
-
- assert(ptransfer);
- if(*ptransfer) {
- tr_tex = trace_texture(tr_scr, (*ptransfer)->texture);
- tr_trans = trace_transfer(tr_tex, *ptransfer);
- transfer = tr_trans->transfer;
- }
- else
- transfer = NULL;
-
- if (*ptransfer) {
- if (!--(*ptransfer)->refcount) {
- trace_dump_call_begin("pipe_screen", "tex_transfer_destroy");
-
- trace_dump_arg(ptr, screen);
- trace_dump_arg(ptr, transfer);
+ struct pipe_texture *texture = transfer->texture;
+ struct pipe_screen *screen = texture->screen;
- trace_transfer_destroy(tr_tex, *ptransfer);
+ trace_dump_call_begin("pipe_screen", "tex_transfer_destroy");
- trace_dump_call_end();
- }
-
- *ptransfer = NULL;
- }
+ trace_dump_arg(ptr, screen);
+ trace_dump_arg(ptr, transfer);
+
+ trace_transfer_destroy(trace_texture(trace_screen(screen), texture),
+ transfer);
+
+ trace_dump_call_end();
}
@@ -509,11 +453,11 @@ trace_screen_create(struct pipe_screen *screen)
tr_scr->base.is_format_supported = trace_screen_is_format_supported;
tr_scr->base.texture_create = trace_screen_texture_create;
tr_scr->base.texture_blanket = trace_screen_texture_blanket;
- tr_scr->base.texture_release = trace_screen_texture_release;
+ tr_scr->base.texture_destroy = trace_screen_texture_destroy;
tr_scr->base.get_tex_surface = trace_screen_get_tex_surface;
- tr_scr->base.tex_surface_release = trace_screen_tex_surface_release;
+ tr_scr->base.tex_surface_destroy = trace_screen_tex_surface_destroy;
tr_scr->base.get_tex_transfer = trace_screen_get_tex_transfer;
- tr_scr->base.tex_transfer_release = trace_screen_tex_transfer_release;
+ tr_scr->base.tex_transfer_destroy = trace_screen_tex_transfer_destroy;
tr_scr->base.transfer_map = trace_screen_transfer_map;
tr_scr->base.transfer_unmap = trace_screen_transfer_unmap;