summaryrefslogtreecommitdiffstats
path: root/src/gallium/drivers
diff options
context:
space:
mode:
Diffstat (limited to 'src/gallium/drivers')
-rw-r--r--src/gallium/drivers/cell/ppu/cell_fence.c6
-rw-r--r--src/gallium/drivers/cell/ppu/cell_texture.c65
-rw-r--r--src/gallium/drivers/failover/fo_context.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_prim_vbuf.c2
-rw-r--r--src/gallium/drivers/i915simple/i915_screen.c16
-rw-r--r--src/gallium/drivers/i915simple/i915_texture.c72
-rw-r--r--src/gallium/drivers/i965simple/brw_tex_layout.c38
-rw-r--r--src/gallium/drivers/i965simple/brw_wm_surface_state.c2
-rw-r--r--src/gallium/drivers/nouveau/nouveau_stateobj.h12
-rw-r--r--src/gallium/drivers/nv04/nv04_miptree.c33
-rw-r--r--src/gallium/drivers/nv04/nv04_transfer.c11
-rw-r--r--src/gallium/drivers/nv10/nv10_miptree.c43
-rw-r--r--src/gallium/drivers/nv10/nv10_prim_vbuf.c6
-rw-r--r--src/gallium/drivers/nv10/nv10_transfer.c11
-rw-r--r--src/gallium/drivers/nv20/nv20_miptree.c46
-rw-r--r--src/gallium/drivers/nv20/nv20_prim_vbuf.c6
-rw-r--r--src/gallium/drivers/nv20/nv20_transfer.c11
-rw-r--r--src/gallium/drivers/nv30/nv30_fragprog.c3
-rw-r--r--src/gallium/drivers/nv30/nv30_miptree.c33
-rw-r--r--src/gallium/drivers/nv30/nv30_transfer.c11
-rw-r--r--src/gallium/drivers/nv40/nv40_fragprog.c3
-rw-r--r--src/gallium/drivers/nv40/nv40_miptree.c33
-rw-r--r--src/gallium/drivers/nv40/nv40_transfer.c11
-rw-r--r--src/gallium/drivers/nv50/nv50_miptree.c41
-rw-r--r--src/gallium/drivers/nv50/nv50_program.c6
-rw-r--r--src/gallium/drivers/nv50/nv50_query.c6
-rw-r--r--src/gallium/drivers/nv50/nv50_screen.c6
-rw-r--r--src/gallium/drivers/nv50/nv50_transfer.c13
-rw-r--r--src/gallium/drivers/r300/r300_screen.c16
-rw-r--r--src/gallium/drivers/r300/r300_swtcl_emit.c5
-rw-r--r--src/gallium/drivers/r300/r300_texture.c48
-rw-r--r--src/gallium/drivers/softpipe/sp_context.c3
-rw-r--r--src/gallium/drivers/softpipe/sp_state_fs.c4
-rw-r--r--src/gallium/drivers/softpipe/sp_texture.c76
-rw-r--r--src/gallium/drivers/softpipe/sp_tile_cache.c14
-rw-r--r--src/gallium/drivers/trace/tr_screen.c122
-rw-r--r--src/gallium/drivers/trace/tr_state.c12
-rw-r--r--src/gallium/drivers/trace/tr_texture.c4
-rw-r--r--src/gallium/drivers/trace/tr_winsys.c8
39 files changed, 295 insertions, 565 deletions
diff --git a/src/gallium/drivers/cell/ppu/cell_fence.c b/src/gallium/drivers/cell/ppu/cell_fence.c
index 32dbf5706c7..13125a9fa30 100644
--- a/src/gallium/drivers/cell/ppu/cell_fence.c
+++ b/src/gallium/drivers/cell/ppu/cell_fence.c
@@ -96,7 +96,7 @@ cell_add_buffer_to_list(struct cell_context *cell,
struct cell_buffer_node *node = CALLOC_STRUCT(cell_buffer_node);
/* create new list node which references the buffer, insert at head */
if (node) {
- pipe_buffer_reference(ps, &node->buffer, buffer);
+ pipe_buffer_reference(&node->buffer, buffer);
node->next = list->head;
list->head = node;
}
@@ -127,10 +127,10 @@ cell_free_fenced_buffers(struct cell_context *cell,
pipe_buffer_unmap(ps, node->buffer);
#if 0
printf("Unref buffer %p\n", node->buffer);
- if (node->buffer->refcount == 1)
+ if (node->buffer->reference.count == 1)
printf(" Delete!\n");
#endif
- pipe_buffer_reference(ps, &node->buffer, NULL);
+ pipe_buffer_reference(&node->buffer, NULL);
FREE(node);
node = next;
}
diff --git a/src/gallium/drivers/cell/ppu/cell_texture.c b/src/gallium/drivers/cell/ppu/cell_texture.c
index 74724393f78..bc6afa94a8b 100644
--- a/src/gallium/drivers/cell/ppu/cell_texture.c
+++ b/src/gallium/drivers/cell/ppu/cell_texture.c
@@ -101,18 +101,17 @@ static struct pipe_texture *
cell_texture_create(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
- struct pipe_winsys *ws = screen->winsys;
struct cell_texture *ct = CALLOC_STRUCT(cell_texture);
if (!ct)
return NULL;
ct->base = *templat;
- ct->base.refcount = 1;
+ pipe_reference_init(&ct->base.reference, 1);
ct->base.screen = screen;
cell_texture_layout(ct);
- ct->buffer = ws->buffer_create(ws, 32, PIPE_BUFFER_USAGE_PIXEL,
+ ct->buffer = screen->buffer_create(screen, 32, PIPE_BUFFER_USAGE_PIXEL,
ct->buffer_size);
if (!ct->buffer) {
@@ -125,28 +124,18 @@ cell_texture_create(struct pipe_screen *screen,
static void
-cell_texture_release(struct pipe_screen *screen,
- struct pipe_texture **pt)
+cell_texture_destroy(struct pipe_texture *pt)
{
- if (!*pt)
- return;
-
- if (--(*pt)->refcount <= 0) {
- /* Delete this texture now.
- * But note that the underlying pipe_buffer may linger...
- */
- struct cell_texture *ct = cell_texture(*pt);
+ struct cell_texture *ct = cell_texture(pt);
- if (ct->mapped) {
- pipe_buffer_unmap(screen, ct->buffer);
- ct->mapped = NULL;
- }
+ if (ct->mapped) {
+ pipe_buffer_unmap(screen, ct->buffer);
+ ct->mapped = NULL;
+ }
- pipe_buffer_reference(screen, &ct->buffer, NULL);
+ pipe_buffer_reference(&ct->buffer, NULL);
- FREE(ct);
- }
- *pt = NULL;
+ FREE(ct);
}
@@ -291,7 +280,7 @@ cell_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
@@ -319,16 +308,10 @@ cell_get_tex_surface(struct pipe_screen *screen,
static void
-cell_tex_surface_release(struct pipe_screen *screen,
- struct pipe_surface **s)
+cell_tex_surface_destroy(struct pipe_surface *s)
{
- struct pipe_surface *surf = *s;
-
- if (--surf->refcount == 0) {
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
- }
- *s = NULL;
+ pipe_texture_reference(&surf->texture, NULL);
+ FREE(surf);
}
@@ -353,7 +336,7 @@ cell_get_tex_transfer(struct pipe_screen *screen,
ctrans = CALLOC_STRUCT(cell_transfer);
if (ctrans) {
struct pipe_transfer *pt = &ctrans->base;
- pt->refcount = 1;
+ pipe_reference_init(&pt->reference, 1);
pipe_texture_reference(&pt->texture, texture);
pt->format = texture->format;
pt->block = texture->block;
@@ -388,20 +371,16 @@ cell_get_tex_transfer(struct pipe_screen *screen,
static void
-cell_tex_transfer_release(struct pipe_screen *screen,
- struct pipe_transfer **t)
+cell_tex_transfer_destroy(struct pipe_transfer *t)
{
- struct cell_transfer *transfer = cell_transfer(*t);
+ struct cell_transfer *transfer = cell_transfer(t);
/* Effectively do the texture_update work here - if texture images
* needed post-processing to put them into hardware layout, this is
* where it would happen. For cell, nothing to do.
*/
assert (transfer->base.texture);
- if (--transfer->base.refcount == 0) {
- pipe_texture_reference(&transfer->base.texture, NULL);
- FREE(transfer);
- }
- *t = NULL;
+ pipe_texture_reference(&transfer->base.texture, NULL);
+ FREE(transfer);
}
@@ -511,13 +490,13 @@ void
cell_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = cell_texture_create;
- screen->texture_release = cell_texture_release;
+ screen->texture_destroy = cell_texture_destroy;
screen->get_tex_surface = cell_get_tex_surface;
- screen->tex_surface_release = cell_tex_surface_release;
+ screen->tex_surface_destroy = cell_tex_surface_destroy;
screen->get_tex_transfer = cell_get_tex_transfer;
- screen->tex_transfer_release = cell_tex_transfer_release;
+ screen->tex_transfer_destroy = cell_tex_transfer_destroy;
screen->transfer_map = cell_transfer_map;
screen->transfer_unmap = cell_transfer_unmap;
diff --git a/src/gallium/drivers/failover/fo_context.c b/src/gallium/drivers/failover/fo_context.c
index 0742b27b8fd..fcad717cf83 100644
--- a/src/gallium/drivers/failover/fo_context.c
+++ b/src/gallium/drivers/failover/fo_context.c
@@ -145,7 +145,7 @@ struct pipe_context *failover_create( struct pipe_context *hw,
#if 0
failover->pipe.texture_create = hw->texture_create;
- failover->pipe.texture_release = hw->texture_release;
+ failover->pipe.texture_destroy = hw->texture_destroy;
failover->pipe.get_tex_surface = hw->get_tex_surface;
failover->pipe.texture_update = hw->texture_update;
#endif
diff --git a/src/gallium/drivers/i915simple/i915_prim_vbuf.c b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
index 58c41840e1f..9bdd91f2881 100644
--- a/src/gallium/drivers/i915simple/i915_prim_vbuf.c
+++ b/src/gallium/drivers/i915simple/i915_prim_vbuf.c
@@ -126,7 +126,7 @@ i915_vbuf_render_allocate_vertices( struct vbuf_render *render,
} else {
i915->vbo_flushed = 0;
if (i915_render->vbo)
- pipe_buffer_reference(screen, &i915_render->vbo, NULL);
+ pipe_buffer_reference(&i915_render->vbo, NULL);
}
if (!i915_render->vbo) {
diff --git a/src/gallium/drivers/i915simple/i915_screen.c b/src/gallium/drivers/i915simple/i915_screen.c
index 49471287a2e..f4aa8e60d81 100644
--- a/src/gallium/drivers/i915simple/i915_screen.c
+++ b/src/gallium/drivers/i915simple/i915_screen.c
@@ -230,7 +230,6 @@ i915_get_tex_transfer(struct pipe_screen *screen,
trans = CALLOC_STRUCT(i915_transfer);
if (trans) {
- trans->base.refcount = 1;
pipe_texture_reference(&trans->base.texture, texture);
trans->base.format = trans->base.format;
trans->base.width = w;
@@ -246,17 +245,10 @@ i915_get_tex_transfer(struct pipe_screen *screen,
}
static void
-i915_tex_transfer_release(struct pipe_screen *screen,
- struct pipe_transfer **transfer)
+i915_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 *
@@ -344,7 +336,7 @@ i915_create_screen(struct pipe_winsys *winsys, uint pci_id)
i915screen->screen.get_paramf = i915_get_paramf;
i915screen->screen.is_format_supported = i915_is_format_supported;
i915screen->screen.get_tex_transfer = i915_get_tex_transfer;
- i915screen->screen.tex_transfer_release = i915_tex_transfer_release;
+ i915screen->screen.tex_transfer_destroy = i915_tex_transfer_destroy;
i915screen->screen.transfer_map = i915_transfer_map;
i915screen->screen.transfer_unmap = i915_transfer_unmap;
diff --git a/src/gallium/drivers/i915simple/i915_texture.c b/src/gallium/drivers/i915simple/i915_texture.c
index 6aead3e75e9..39aca9f8173 100644
--- a/src/gallium/drivers/i915simple/i915_texture.c
+++ b/src/gallium/drivers/i915simple/i915_texture.c
@@ -582,7 +582,6 @@ i915_texture_create(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
struct i915_screen *i915screen = i915_screen(screen);
- struct pipe_winsys *ws = screen->winsys;
struct i915_texture *tex = CALLOC_STRUCT(i915_texture);
size_t tex_size;
@@ -590,7 +589,7 @@ i915_texture_create(struct pipe_screen *screen,
return NULL;
tex->base = *templat;
- tex->base.refcount = 1;
+ pipe_reference_init(&tex->base.reference, 1);
tex->base.screen = screen;
tex->base.nblocksx[0] = pf_get_nblocksx(&tex->base.block, tex->base.width[0]);
@@ -606,7 +605,7 @@ i915_texture_create(struct pipe_screen *screen,
tex_size = tex->stride * tex->total_nblocksy;
- tex->buffer = ws->buffer_create(ws, 64,
+ tex->buffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex_size);
@@ -629,33 +628,22 @@ fail:
static void
-i915_texture_release(struct pipe_screen *screen,
- struct pipe_texture **pt)
+i915_texture_destroy(struct pipe_texture *pt)
{
- if (!*pt)
- return;
+ struct i915_texture *tex = (struct i915_texture *)pt;
+ uint i;
/*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
+ DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- if (--(*pt)->refcount <= 0) {
- struct i915_texture *tex = (struct i915_texture *)*pt;
- uint i;
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
- pipe_buffer_reference(screen, &tex->buffer, NULL);
+ pipe_buffer_reference(&tex->buffer, NULL);
- for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
- if (tex->image_offset[i])
- FREE(tex->image_offset[i]);
+ for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
+ if (tex->image_offset[i])
+ FREE(tex->image_offset[i]);
- FREE(tex);
- }
- *pt = NULL;
+ FREE(tex);
}
static struct pipe_surface *
@@ -682,7 +670,7 @@ i915_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
@@ -715,7 +703,7 @@ i915_texture_blanket(struct pipe_screen * screen,
return NULL;
tex->base = *base;
- tex->base.refcount = 1;
+ pipe_reference_init(&tex->base.reference, 1);
tex->base.screen = screen;
tex->stride = stride[0];
@@ -723,7 +711,7 @@ i915_texture_blanket(struct pipe_screen * screen,
i915_miptree_set_level_info(tex, 0, 1, base->width[0], base->height[0], 1);
i915_miptree_set_image_offset(tex, 0, 0, 0, 0);
- pipe_buffer_reference(screen, &tex->buffer, buffer);
+ pipe_buffer_reference(&tex->buffer, buffer);
return &tex->base;
}
@@ -735,36 +723,28 @@ i915_init_texture_functions(struct i915_context *i915)
}
static void
-i915_tex_surface_release(struct pipe_screen *screen,
- struct pipe_surface **surface)
+i915_tex_surface_destroy(struct pipe_surface *surf)
{
- struct pipe_surface *surf = *surface;
-
- if (--surf->refcount == 0) {
-
- /* This really should not be possible, but it's actually
- * happening quite a bit... Will fix.
- */
- if (surf->status == PIPE_SURFACE_STATUS_CLEAR) {
- debug_printf("XXX destroying a surface with pending clears...\n");
- assert(0);
- }
-
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
+ /* This really should not be possible, but it's actually
+ * happening quite a bit... Will fix.
+ */
+ if (surf->status == PIPE_SURFACE_STATUS_CLEAR) {
+ debug_printf("XXX destroying a surface with pending clears...\n");
+ assert(0);
}
- *surface = NULL;
+ pipe_texture_reference(&surf->texture, NULL);
+ FREE(surf);
}
void
i915_init_screen_texture_functions(struct pipe_screen *screen)
{
screen->texture_create = i915_texture_create;
- screen->texture_release = i915_texture_release;
+ screen->texture_destroy = i915_texture_destroy;
screen->get_tex_surface = i915_get_tex_surface;
screen->texture_blanket = i915_texture_blanket;
- screen->tex_surface_release = i915_tex_surface_release;
+ screen->tex_surface_destroy = i915_tex_surface_destroy;
}
boolean i915_get_texture_buffer( struct pipe_texture *texture,
@@ -776,7 +756,7 @@ boolean i915_get_texture_buffer( struct pipe_texture *texture,
if (!tex)
return FALSE;
- pipe_buffer_reference(texture->screen, buf, tex->buffer);
+ pipe_buffer_reference(buf, tex->buffer);
if (stride)
*stride = tex->stride;
diff --git a/src/gallium/drivers/i965simple/brw_tex_layout.c b/src/gallium/drivers/i965simple/brw_tex_layout.c
index 448229ed4ee..c921c0d38be 100644
--- a/src/gallium/drivers/i965simple/brw_tex_layout.c
+++ b/src/gallium/drivers/i965simple/brw_tex_layout.c
@@ -284,18 +284,17 @@ static struct pipe_texture *
brw_texture_create_screen(struct pipe_screen *screen,
const struct pipe_texture *templat)
{
- struct pipe_winsys *ws = screen->winsys;
struct brw_texture *tex = CALLOC_STRUCT(brw_texture);
if (tex) {
tex->base = *templat;
- tex->base.refcount = 1;
+ pipe_reference_init(&tex->base.reference, 1);
tex->base.nblocksx[0] = pf_get_nblocksx(&tex->base.block, tex->base.width[0]);
tex->base.nblocksy[0] = pf_get_nblocksy(&tex->base.block, tex->base.height[0]);
if (brw_miptree_layout(tex))
- tex->buffer = ws->buffer_create(ws, 64,
+ tex->buffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_PIXEL,
tex->stride *
tex->total_nblocksy);
@@ -311,33 +310,22 @@ brw_texture_create_screen(struct pipe_screen *screen,
static void
-brw_texture_release_screen(struct pipe_screen *screen,
- struct pipe_texture **pt)
+brw_texture_destroy_screen(struct pipe_texture *pt)
{
- if (!*pt)
- return;
+ struct brw_texture *tex = (struct brw_texture *)pt;
+ uint i;
/*
- DBG("%s %p refcount will be %d\n",
- __FUNCTION__, (void *) *pt, (*pt)->refcount - 1);
+ DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
*/
- if (--(*pt)->refcount <= 0) {
- struct brw_texture *tex = (struct brw_texture *)*pt;
- uint i;
-
- /*
- DBG("%s deleting %p\n", __FUNCTION__, (void *) tex);
- */
- pipe_buffer_reference(screen, &tex->buffer, NULL);
+ pipe_buffer_reference(&tex->buffer, NULL);
- for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
- if (tex->image_offset[i])
- free(tex->image_offset[i]);
+ for (i = 0; i < PIPE_MAX_TEXTURE_LEVELS; i++)
+ if (tex->image_offset[i])
+ free(tex->image_offset[i]);
- free(tex);
- }
- *pt = NULL;
+ free(tex);
}
@@ -365,7 +353,7 @@ brw_get_tex_surface_screen(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
@@ -392,7 +380,7 @@ void
brw_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = brw_texture_create_screen;
- screen->texture_release = brw_texture_release_screen;
+ screen->texture_destroy = brw_texture_destroy_screen;
screen->get_tex_surface = brw_get_tex_surface_screen;
}
diff --git a/src/gallium/drivers/i965simple/brw_wm_surface_state.c b/src/gallium/drivers/i965simple/brw_wm_surface_state.c
index 1bab5bfdb3a..b5b9e0e7026 100644
--- a/src/gallium/drivers/i965simple/brw_wm_surface_state.c
+++ b/src/gallium/drivers/i965simple/brw_wm_surface_state.c
@@ -242,7 +242,7 @@ static void upload_wm_surfaces(struct brw_context *brw )
const struct brw_texture *texUnit = brw->attribs.Texture[i];
if (texUnit &&
- texUnit->base.refcount/*(texUnit->refcount > 0) == really used */) {
+ texUnit->base.reference.count/*(texUnit->reference.count > 0) == really used */) {
brw_update_texture_surface(brw, i);
diff --git a/src/gallium/drivers/nouveau/nouveau_stateobj.h b/src/gallium/drivers/nouveau/nouveau_stateobj.h
index 029b01e17d5..666e061ac38 100644
--- a/src/gallium/drivers/nouveau/nouveau_stateobj.h
+++ b/src/gallium/drivers/nouveau/nouveau_stateobj.h
@@ -16,7 +16,7 @@ struct nouveau_stateobj_reloc {
};
struct nouveau_stateobj {
- int refcount;
+ struct pipe_reference reference;
unsigned *push;
struct nouveau_stateobj_reloc *reloc;
@@ -32,7 +32,7 @@ so_new(unsigned push, unsigned reloc)
struct nouveau_stateobj *so;
so = MALLOC(sizeof(struct nouveau_stateobj));
- so->refcount = 0;
+ pipe_reference_init(&so->reference, 0);
so->push = MALLOC(sizeof(unsigned) * push);
so->reloc = MALLOC(sizeof(struct nouveau_stateobj_reloc) * reloc);
@@ -47,17 +47,11 @@ so_ref(struct nouveau_stateobj *ref, struct nouveau_stateobj **pso)
{
struct nouveau_stateobj *so = *pso;
- if (ref) {
- ref->refcount++;
- }
-
- if (so && --so->refcount <= 0) {
+ if (pipe_reference((struct pipe_reference**)pso, &ref->reference)) {
free(so->push);
free(so->reloc);
free(so);
}
-
- *pso = ref;
}
static INLINE void
diff --git a/src/gallium/drivers/nv04/nv04_miptree.c b/src/gallium/drivers/nv04/nv04_miptree.c
index 9acd613e2e4..85dc017fbc4 100644
--- a/src/gallium/drivers/nv04/nv04_miptree.c
+++ b/src/gallium/drivers/nv04/nv04_miptree.c
@@ -41,21 +41,20 @@ nv04_miptree_layout(struct nv04_miptree *nv04mt)
static struct pipe_texture *
nv04_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv04_miptree *mt;
mt = MALLOC(sizeof(struct nv04_miptree));
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
//mt->base.tex_usage |= NOUVEAU_TEXTURE_USAGE_LINEAR;
nv04_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL |
+ mt->buffer = pscreen->buffer_create(pscreen, 256, PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE,
mt->total_size);
if (!mt->buffer) {
@@ -83,27 +82,22 @@ nv04_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv04_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv04_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
struct nv04_miptree *mt = (struct nv04_miptree *)pt;
int l;
- *ppt = NULL;
- if (--pt->refcount)
- return;
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
+ pipe_buffer_reference(&mt->buffer, NULL);
for (l = 0; l <= pt->last_level; l++) {
if (mt->level[l].image_offset)
FREE(mt->level[l].image_offset);
@@ -129,7 +123,7 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
@@ -141,15 +135,8 @@ nv04_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv04_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv04_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
@@ -159,8 +146,8 @@ nv04_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv04_miptree_create;
pscreen->texture_blanket = nv04_miptree_blanket;
- pscreen->texture_release = nv04_miptree_release;
+ pscreen->texture_destroy = nv04_miptree_destroy;
pscreen->get_tex_surface = nv04_miptree_surface_new;
- pscreen->tex_surface_release = nv04_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv04_miptree_surface_del;
}
diff --git a/src/gallium/drivers/nv04/nv04_transfer.c b/src/gallium/drivers/nv04/nv04_transfer.c
index 573b043f5b6..e925a44e298 100644
--- a/src/gallium/drivers/nv04/nv04_transfer.c
+++ b/src/gallium/drivers/nv04/nv04_transfer.c
@@ -64,7 +64,6 @@ nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
@@ -138,12 +137,12 @@ nv04_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv04_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv04_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv04_transfer *tx = (struct nv04_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv04_screen *nvscreen = nv04_screen(pscreen);
struct pipe_surface *dst;
@@ -160,10 +159,6 @@ nv04_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
@@ -195,7 +190,7 @@ void
nv04_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv04_transfer_new;
- pscreen->tex_transfer_release = nv04_transfer_del;
+ pscreen->tex_transfer_destroy = nv04_transfer_del;
pscreen->transfer_map = nv04_transfer_map;
pscreen->transfer_unmap = nv04_transfer_unmap;
}
diff --git a/src/gallium/drivers/nv10/nv10_miptree.c b/src/gallium/drivers/nv10/nv10_miptree.c
index 4747868a508..bb3a1c0f19e 100644
--- a/src/gallium/drivers/nv10/nv10_miptree.c
+++ b/src/gallium/drivers/nv10/nv10_miptree.c
@@ -66,31 +66,30 @@ nv10_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static struct pipe_texture *
nv10_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = screen->winsys;
struct nv10_miptree *mt;
mt = MALLOC(sizeof(struct nv10_miptree));
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = screen;
nv10_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, PIPE_BUFFER_USAGE_PIXEL,
+ mt->buffer = screen->buffer_create(screen, 256, PIPE_BUFFER_USAGE_PIXEL,
mt->total_size);
if (!mt->buffer) {
FREE(mt);
@@ -101,22 +100,17 @@ nv10_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
}
static void
-nv10_miptree_release(struct pipe_screen *screen, struct pipe_texture **pt)
+nv10_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *mt = *pt;
-
- *pt = NULL;
- if (--mt->refcount <= 0) {
- struct nv10_miptree *nv10mt = (struct nv10_miptree *)mt;
- int l;
-
- pipe_buffer_reference(screen, &nv10mt->buffer, NULL);
- for (l = 0; l <= mt->last_level; l++) {
- if (nv10mt->level[l].image_offset)
- FREE(nv10mt->level[l].image_offset);
- }
- FREE(nv10mt);
- }
+ struct nv10_miptree *nv10mt = (struct nv10_miptree *)pt;
+ int l;
+
+ pipe_buffer_reference(&nv10mt->buffer, NULL);
+ for (l = 0; l <= pt->last_level; l++) {
+ if (nv10mt->level[l].image_offset)
+ FREE(nv10mt->level[l].image_offset);
+ }
+ FREE(nv10mt);
}
static void
@@ -143,7 +137,7 @@ nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
@@ -159,8 +153,7 @@ nv10_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
}
static void
-nv10_miptree_surface_release(struct pipe_screen *screen,
- struct pipe_surface **surface)
+nv10_miptree_surface_destroy(struct pipe_surface *surface)
{
}
@@ -168,8 +161,8 @@ void nv10_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv10_miptree_create;
pscreen->texture_blanket = nv10_miptree_blanket;
- pscreen->texture_release = nv10_miptree_release;
+ pscreen->texture_destroy = nv10_miptree_destroy;
pscreen->get_tex_surface = nv10_miptree_surface_get;
- pscreen->tex_surface_release = nv10_miptree_surface_release;
+ pscreen->tex_surface_destroy = nv10_miptree_surface_destroy;
}
diff --git a/src/gallium/drivers/nv10/nv10_prim_vbuf.c b/src/gallium/drivers/nv10/nv10_prim_vbuf.c
index 491a8818068..089c236302a 100644
--- a/src/gallium/drivers/nv10/nv10_prim_vbuf.c
+++ b/src/gallium/drivers/nv10/nv10_prim_vbuf.c
@@ -106,11 +106,11 @@ nv10_vbuf_render_allocate_vertices( struct vbuf_render *render,
{
struct nv10_vbuf_render *nv10_render = nv10_vbuf_render(render);
struct nv10_context *nv10 = nv10_render->nv10;
- struct pipe_winsys *winsys = nv10->pipe.winsys;
+ struct pipe_screen *screen = nv10->pipe.screen;
size_t size = (size_t)vertex_size * (size_t)nr_vertices;
assert(!nv10_render->buffer);
- nv10_render->buffer = winsys->buffer_create(winsys, 64, PIPE_BUFFER_USAGE_VERTEX, size);
+ nv10_render->buffer = screen->buffer_create(screen, 64, PIPE_BUFFER_USAGE_VERTEX, size);
nv10->dirty |= NV10_NEW_VTXARRAYS;
@@ -206,7 +206,7 @@ nv10_vbuf_render_release_vertices( struct vbuf_render *render )
struct pipe_screen *pscreen = &nv10->screen->pipe;
assert(nv10_render->buffer);
- pipe_buffer_reference(pscreen, &nv10_render->buffer, NULL);
+ pipe_buffer_reference(&nv10_render->buffer, NULL);
}
diff --git a/src/gallium/drivers/nv10/nv10_transfer.c b/src/gallium/drivers/nv10/nv10_transfer.c
index daec37ab28e..5a99225409c 100644
--- a/src/gallium/drivers/nv10/nv10_transfer.c
+++ b/src/gallium/drivers/nv10/nv10_transfer.c
@@ -64,7 +64,6 @@ nv10_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
@@ -138,12 +137,12 @@ nv10_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv10_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv10_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv10_transfer *tx = (struct nv10_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv10_screen *nvscreen = nv10_screen(pscreen);
struct pipe_surface *dst;
@@ -160,10 +159,6 @@ nv10_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
@@ -195,7 +190,7 @@ void
nv10_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv10_transfer_new;
- pscreen->tex_transfer_release = nv10_transfer_del;
+ pscreen->tex_transfer_destroy = nv10_transfer_del;
pscreen->transfer_map = nv10_transfer_map;
pscreen->transfer_unmap = nv10_transfer_unmap;
}
diff --git a/src/gallium/drivers/nv20/nv20_miptree.c b/src/gallium/drivers/nv20/nv20_miptree.c
index 29462408970..b2f29aff8d2 100644
--- a/src/gallium/drivers/nv20/nv20_miptree.c
+++ b/src/gallium/drivers/nv20/nv20_miptree.c
@@ -76,19 +76,18 @@ nv20_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static struct pipe_texture *
nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = screen->winsys;
struct nv20_miptree *mt;
unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE;
@@ -97,7 +96,7 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = screen;
/* Swizzled textures must be POT */
@@ -133,7 +132,7 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
nv20_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, buf_usage, mt->total_size);
+ mt->buffer = screen->buffer_create(screen, 256, buf_usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
@@ -143,22 +142,16 @@ nv20_miptree_create(struct pipe_screen *screen, const struct pipe_texture *pt)
}
static void
-nv20_miptree_release(struct pipe_screen *screen, struct pipe_texture **pt)
+nv20_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *mt = *pt;
-
- *pt = NULL;
- if (--mt->refcount <= 0) {
- struct nv20_miptree *nv20mt = (struct nv20_miptree *)mt;
- int l;
+ struct nv20_miptree *nv20mt = (struct nv20_miptree *)pt;
+ int l;
- pipe_buffer_reference(screen, &nv20mt->buffer, NULL);
- for (l = 0; l <= mt->last_level; l++) {
- if (nv20mt->level[l].image_offset)
- FREE(nv20mt->level[l].image_offset);
- }
- FREE(nv20mt);
- }
+ pipe_buffer_reference(&nv20mt->buffer, NULL);
+ for (l = 0; l <= pt->last_level; l++) {
+ if (nv20mt->level[l].image_offset)
+ FREE(nv20mt->level[l].image_offset);
+ }
}
static struct pipe_surface *
@@ -178,7 +171,7 @@ nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
@@ -197,15 +190,8 @@ nv20_miptree_surface_get(struct pipe_screen *screen, struct pipe_texture *pt,
}
static void
-nv20_miptree_surface_release(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv20_miptree_surface_destroy(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
@@ -214,8 +200,8 @@ void nv20_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv20_miptree_create;
pscreen->texture_blanket = nv20_miptree_blanket;
- pscreen->texture_release = nv20_miptree_release;
+ pscreen->texture_destroy = nv20_miptree_destroy;
pscreen->get_tex_surface = nv20_miptree_surface_get;
- pscreen->tex_surface_release = nv20_miptree_surface_release;
+ pscreen->tex_surface_destroy = nv20_miptree_surface_destroy;
}
diff --git a/src/gallium/drivers/nv20/nv20_prim_vbuf.c b/src/gallium/drivers/nv20/nv20_prim_vbuf.c
index 319e1f65572..8aa342cd2db 100644
--- a/src/gallium/drivers/nv20/nv20_prim_vbuf.c
+++ b/src/gallium/drivers/nv20/nv20_prim_vbuf.c
@@ -112,8 +112,8 @@ nv20__allocate_mbuffer(struct nv20_vbuf_render *nv20_render, size_t size)
static void
nv20__allocate_pbuffer(struct nv20_vbuf_render *nv20_render, size_t size)
{
- struct pipe_winsys *winsys = nv20_render->nv20->pipe.winsys;
- nv20_render->pbuffer = winsys->buffer_create(winsys, 64,
+ struct pipe_screen *screen = nv20_render->nv20->pipe.screen;
+ nv20_render->pbuffer = screen->buffer_create(screen, 64,
PIPE_BUFFER_USAGE_VERTEX, size);
}
@@ -361,7 +361,7 @@ nv20_vbuf_render_release_vertices( struct vbuf_render *render )
struct pipe_screen *pscreen = &nv20->screen->pipe;
if (nv20_render->pbuffer) {
- pipe_buffer_reference(pscreen, &nv20_render->pbuffer, NULL);
+ pipe_buffer_reference(&nv20_render->pbuffer, NULL);
} else if (nv20_render->mbuffer) {
FREE(nv20_render->mbuffer);
nv20_render->mbuffer = NULL;
diff --git a/src/gallium/drivers/nv20/nv20_transfer.c b/src/gallium/drivers/nv20/nv20_transfer.c
index 1631637067d..e5255296aae 100644
--- a/src/gallium/drivers/nv20/nv20_transfer.c
+++ b/src/gallium/drivers/nv20/nv20_transfer.c
@@ -64,7 +64,6 @@ nv20_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
@@ -138,12 +137,12 @@ nv20_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv20_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv20_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv20_transfer *tx = (struct nv20_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv20_screen *nvscreen = nv20_screen(pscreen);
struct pipe_surface *dst;
@@ -160,10 +159,6 @@ nv20_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
@@ -195,7 +190,7 @@ void
nv20_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv20_transfer_new;
- pscreen->tex_transfer_release = nv20_transfer_del;
+ pscreen->tex_transfer_destroy = nv20_transfer_del;
pscreen->transfer_map = nv20_transfer_map;
pscreen->transfer_unmap = nv20_transfer_unmap;
}
diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c b/src/gallium/drivers/nv30/nv30_fragprog.c
index 320ba3f4bf4..0da392fed33 100644
--- a/src/gallium/drivers/nv30/nv30_fragprog.c
+++ b/src/gallium/drivers/nv30/nv30_fragprog.c
@@ -834,6 +834,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
struct nv30_fragment_program *fp = nv30->fragprog;
struct pipe_buffer *constbuf =
nv30->constbuf[PIPE_SHADER_FRAGMENT];
+ struct pipe_screen *screen = nv30->pipe.screen;
struct pipe_winsys *ws = nv30->pipe.winsys;
struct nouveau_stateobj *so;
boolean new_consts = FALSE;
@@ -849,7 +850,7 @@ nv30_fragprog_validate(struct nv30_context *nv30)
return FALSE;
}
- fp->buffer = ws->buffer_create(ws, 0x100, 0, fp->insn_len * 4);
+ fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4);
nv30_fragprog_upload(nv30, fp);
so = so_new(8, 1);
diff --git a/src/gallium/drivers/nv30/nv30_miptree.c b/src/gallium/drivers/nv30/nv30_miptree.c
index ec0a8b8438c..d6dc621c9ee 100644
--- a/src/gallium/drivers/nv30/nv30_miptree.c
+++ b/src/gallium/drivers/nv30/nv30_miptree.c
@@ -67,7 +67,6 @@ nv30_miptree_layout(struct nv30_miptree *nv30mt)
static struct pipe_texture *
nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv30_miptree *mt;
unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE;
@@ -76,7 +75,7 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
/* Swizzled textures must be POT */
@@ -112,7 +111,7 @@ nv30_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
nv30_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, buf_usage,
+ mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage,
mt->total_size);
if (!mt->buffer) {
FREE(mt);
@@ -138,27 +137,22 @@ nv30_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv30_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv30_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
struct nv30_miptree *mt = (struct nv30_miptree *)pt;
int l;
- *ppt = NULL;
- if (--pt->refcount)
- return;
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
+ pipe_buffer_reference(&mt->buffer, NULL);
for (l = 0; l <= pt->last_level; l++) {
if (mt->level[l].image_offset)
FREE(mt->level[l].image_offset);
@@ -184,7 +178,7 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
@@ -203,15 +197,8 @@ nv30_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv30_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv30_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
@@ -221,7 +208,7 @@ nv30_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv30_miptree_create;
pscreen->texture_blanket = nv30_miptree_blanket;
- pscreen->texture_release = nv30_miptree_release;
+ pscreen->texture_destroy = nv30_miptree_destroy;
pscreen->get_tex_surface = nv30_miptree_surface_new;
- pscreen->tex_surface_release = nv30_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv30_miptree_surface_del;
}
diff --git a/src/gallium/drivers/nv30/nv30_transfer.c b/src/gallium/drivers/nv30/nv30_transfer.c
index 6367374a616..8b915b35bd4 100644
--- a/src/gallium/drivers/nv30/nv30_transfer.c
+++ b/src/gallium/drivers/nv30/nv30_transfer.c
@@ -64,7 +64,6 @@ nv30_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
@@ -138,12 +137,12 @@ nv30_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv30_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv30_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv30_transfer *tx = (struct nv30_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv30_screen *nvscreen = nv30_screen(pscreen);
struct pipe_surface *dst;
@@ -160,10 +159,6 @@ nv30_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
@@ -195,7 +190,7 @@ void
nv30_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv30_transfer_new;
- pscreen->tex_transfer_release = nv30_transfer_del;
+ pscreen->tex_transfer_destroy = nv30_transfer_del;
pscreen->transfer_map = nv30_transfer_map;
pscreen->transfer_unmap = nv30_transfer_unmap;
}
diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c b/src/gallium/drivers/nv40/nv40_fragprog.c
index 91dcbebda0d..1031e87e970 100644
--- a/src/gallium/drivers/nv40/nv40_fragprog.c
+++ b/src/gallium/drivers/nv40/nv40_fragprog.c
@@ -917,6 +917,7 @@ nv40_fragprog_validate(struct nv40_context *nv40)
struct nv40_fragment_program *fp = nv40->fragprog;
struct pipe_buffer *constbuf =
nv40->constbuf[PIPE_SHADER_FRAGMENT];
+ struct pipe_screen *screen = nv40->pipe.screen;
struct pipe_winsys *ws = nv40->pipe.winsys;
struct nouveau_stateobj *so;
boolean new_consts = FALSE;
@@ -932,7 +933,7 @@ nv40_fragprog_validate(struct nv40_context *nv40)
return FALSE;
}
- fp->buffer = ws->buffer_create(ws, 0x100, 0, fp->insn_len * 4);
+ fp->buffer = screen->buffer_create(screen, 0x100, 0, fp->insn_len * 4);
nv40_fragprog_upload(nv40, fp);
so = so_new(4, 1);
diff --git a/src/gallium/drivers/nv40/nv40_miptree.c b/src/gallium/drivers/nv40/nv40_miptree.c
index 638d279aa5a..abadca8c933 100644
--- a/src/gallium/drivers/nv40/nv40_miptree.c
+++ b/src/gallium/drivers/nv40/nv40_miptree.c
@@ -67,7 +67,6 @@ nv40_miptree_layout(struct nv40_miptree *mt)
static struct pipe_texture *
nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv40_miptree *mt;
unsigned buf_usage = PIPE_BUFFER_USAGE_PIXEL |
NOUVEAU_BUFFER_USAGE_TEXTURE;
@@ -76,7 +75,7 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
if (!mt)
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
/* Swizzled textures must be POT */
@@ -112,7 +111,7 @@ nv40_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *pt)
nv40_miptree_layout(mt);
- mt->buffer = ws->buffer_create(ws, 256, buf_usage, mt->total_size);
+ mt->buffer = pscreen->buffer_create(pscreen, 256, buf_usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
@@ -137,27 +136,22 @@ nv40_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->level[0].pitch = stride[0];
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv40_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv40_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
struct nv40_miptree *mt = (struct nv40_miptree *)pt;
int l;
- *ppt = NULL;
- if (--pt->refcount)
- return;
-
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
+ pipe_buffer_reference(&mt->buffer, NULL);
for (l = 0; l <= pt->last_level; l++) {
if (mt->level[l].image_offset)
FREE(mt->level[l].image_offset);
@@ -183,7 +177,7 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ns->base.height = pt->height[level];
ns->base.usage = flags;
ns->base.status = PIPE_SURFACE_STATUS_DEFINED;
- ns->base.refcount = 1;
+ pipe_reference_init(&ns->base.reference, 1);
ns->base.face = face;
ns->base.level = level;
ns->base.zslice = zslice;
@@ -202,15 +196,8 @@ nv40_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv40_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv40_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
-
- *psurface = NULL;
- if (--ps->refcount > 0)
- return;
-
pipe_texture_reference(&ps->texture, NULL);
FREE(ps);
}
@@ -220,8 +207,8 @@ nv40_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv40_miptree_create;
pscreen->texture_blanket = nv40_miptree_blanket;
- pscreen->texture_release = nv40_miptree_release;
+ pscreen->texture_destroy = nv40_miptree_destroy;
pscreen->get_tex_surface = nv40_miptree_surface_new;
- pscreen->tex_surface_release = nv40_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv40_miptree_surface_del;
}
diff --git a/src/gallium/drivers/nv40/nv40_transfer.c b/src/gallium/drivers/nv40/nv40_transfer.c
index f762f32f0c3..728e8b56745 100644
--- a/src/gallium/drivers/nv40/nv40_transfer.c
+++ b/src/gallium/drivers/nv40/nv40_transfer.c
@@ -64,7 +64,6 @@ nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.x = x;
@@ -138,12 +137,12 @@ nv40_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv40_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv40_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv40_transfer *tx = (struct nv40_transfer *)ptx;
if (!tx->direct && ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
struct nv40_screen *nvscreen = nv40_screen(pscreen);
struct pipe_surface *dst;
@@ -160,10 +159,6 @@ nv40_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
pipe_surface_reference(&dst, NULL);
}
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
pipe_surface_reference(&tx->surface, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
@@ -195,7 +190,7 @@ void
nv40_screen_init_transfer_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv40_transfer_new;
- pscreen->tex_transfer_release = nv40_transfer_del;
+ pscreen->tex_transfer_destroy = nv40_transfer_del;
pscreen->transfer_map = nv40_transfer_map;
pscreen->transfer_unmap = nv40_transfer_unmap;
}
diff --git a/src/gallium/drivers/nv50/nv50_miptree.c b/src/gallium/drivers/nv50/nv50_miptree.c
index 24a68b7235f..dc4688ccdc4 100644
--- a/src/gallium/drivers/nv50/nv50_miptree.c
+++ b/src/gallium/drivers/nv50/nv50_miptree.c
@@ -29,7 +29,6 @@
static struct pipe_texture *
nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
{
- struct pipe_winsys *ws = pscreen->winsys;
struct nv50_miptree *mt = CALLOC_STRUCT(nv50_miptree);
struct pipe_texture *pt = &mt->base;
unsigned usage, width = tmp->width[0], height = tmp->height[0];
@@ -37,7 +36,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
int i, l;
mt->base = *tmp;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
usage = PIPE_BUFFER_USAGE_PIXEL;
@@ -94,7 +93,7 @@ nv50_miptree_create(struct pipe_screen *pscreen, const struct pipe_texture *tmp)
}
}
- mt->buffer = ws->buffer_create(ws, 256, usage, mt->total_size);
+ mt->buffer = pscreen->buffer_create(pscreen, 256, usage, mt->total_size);
if (!mt->buffer) {
FREE(mt);
return NULL;
@@ -119,29 +118,23 @@ nv50_miptree_blanket(struct pipe_screen *pscreen, const struct pipe_texture *pt,
return NULL;
mt->base = *pt;
- mt->base.refcount = 1;
+ pipe_reference_init(&mt->base.reference, 1);
mt->base.screen = pscreen;
mt->image_nr = 1;
mt->level[0].pitch = *stride;
mt->level[0].image_offset = CALLOC(1, sizeof(unsigned));
- pipe_buffer_reference(pscreen, &mt->buffer, pb);
+ pipe_buffer_reference(&mt->buffer, pb);
return &mt->base;
}
static void
-nv50_miptree_release(struct pipe_screen *pscreen, struct pipe_texture **ppt)
+nv50_miptree_destroy(struct pipe_texture *pt)
{
- struct pipe_texture *pt = *ppt;
-
- *ppt = NULL;
-
- if (--pt->refcount <= 0) {
- struct nv50_miptree *mt = nv50_miptree(pt);
+ struct nv50_miptree *mt = nv50_miptree(pt);
- pipe_buffer_reference(pscreen, &mt->buffer, NULL);
- FREE(mt);
- }
+ pipe_buffer_reference(&mt->buffer, NULL);
+ FREE(mt);
}
static struct pipe_surface *
@@ -171,7 +164,7 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
ps->height = pt->height[level];
ps->usage = flags;
ps->status = PIPE_SURFACE_STATUS_DEFINED;
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
ps->face = face;
ps->level = level;
ps->zslice = zslice;
@@ -181,18 +174,12 @@ nv50_miptree_surface_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv50_miptree_surface_del(struct pipe_screen *pscreen,
- struct pipe_surface **psurface)
+nv50_miptree_surface_del(struct pipe_surface *ps)
{
- struct pipe_surface *ps = *psurface;
struct nv50_surface *s = nv50_surface(ps);
- *psurface = NULL;
-
- if (--ps->refcount <= 0) {
- pipe_texture_reference(&ps->texture, NULL);
- FREE(s);
- }
+ pipe_texture_reference(&ps->texture, NULL);
+ FREE(s);
}
void
@@ -200,8 +187,8 @@ nv50_screen_init_miptree_functions(struct pipe_screen *pscreen)
{
pscreen->texture_create = nv50_miptree_create;
pscreen->texture_blanket = nv50_miptree_blanket;
- pscreen->texture_release = nv50_miptree_release;
+ pscreen->texture_destroy = nv50_miptree_destroy;
pscreen->get_tex_surface = nv50_miptree_surface_new;
- pscreen->tex_surface_release = nv50_miptree_surface_del;
+ pscreen->tex_surface_destroy = nv50_miptree_surface_del;
}
diff --git a/src/gallium/drivers/nv50/nv50_program.c b/src/gallium/drivers/nv50/nv50_program.c
index 14c5d47e790..308eb34784c 100644
--- a/src/gallium/drivers/nv50/nv50_program.c
+++ b/src/gallium/drivers/nv50/nv50_program.c
@@ -1603,7 +1603,7 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
{
struct nouveau_channel *chan = nv50->screen->nvws->channel;
struct nouveau_grobj *tesla = nv50->screen->tesla;
- struct pipe_winsys *ws = nv50->pipe.winsys;
+ struct pipe_screen *screen = nv50->pipe.screen;
struct nv50_program_exec *e;
struct nouveau_stateobj *so;
const unsigned flags = NOUVEAU_BO_VRAM | NOUVEAU_BO_WR;
@@ -1611,7 +1611,7 @@ nv50_program_validate_code(struct nv50_context *nv50, struct nv50_program *p)
boolean upload = FALSE;
if (!p->buffer) {
- p->buffer = ws->buffer_create(ws, 0x100, 0, p->exec_size * 4);
+ p->buffer = screen->buffer_create(screen, 0x100, 0, p->exec_size * 4);
upload = TRUE;
}
@@ -1775,7 +1775,7 @@ nv50_program_destroy(struct nv50_context *nv50, struct nv50_program *p)
p->exec_size = 0;
if (p->buffer)
- pipe_buffer_reference(pscreen, &p->buffer, NULL);
+ pipe_buffer_reference(&p->buffer, NULL);
nv50->screen->nvws->res_free(&p->data);
diff --git a/src/gallium/drivers/nv50/nv50_query.c b/src/gallium/drivers/nv50/nv50_query.c
index 7c8831a46de..a2c56f99a89 100644
--- a/src/gallium/drivers/nv50/nv50_query.c
+++ b/src/gallium/drivers/nv50/nv50_query.c
@@ -41,13 +41,13 @@ nv50_query(struct pipe_query *pipe)
static struct pipe_query *
nv50_query_create(struct pipe_context *pipe, unsigned type)
{
- struct pipe_winsys *ws = pipe->winsys;
+ struct pipe_screen *screen = pipe->winsys;
struct nv50_query *q = CALLOC_STRUCT(nv50_query);
assert (q->type == PIPE_QUERY_OCCLUSION_COUNTER);
q->type = type;
- q->buffer = ws->buffer_create(ws, 256, 0, 16);
+ q->buffer = screen->buffer_create(screen, 256, 0, 16);
if (!q->buffer) {
FREE(q);
return NULL;
@@ -62,7 +62,7 @@ nv50_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
struct nv50_query *q = nv50_query(pq);
if (q) {
- pipe_buffer_reference(pipe->screen, &q->buffer, NULL);
+ pipe_buffer_reference(&q->buffer, NULL);
FREE(q);
}
}
diff --git a/src/gallium/drivers/nv50/nv50_screen.c b/src/gallium/drivers/nv50/nv50_screen.c
index ee24405d36d..bbfe42e4789 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -285,7 +285,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
so_data (so, 8);
/* Shared constant buffer */
- screen->constbuf = ws->buffer_create(ws, 0, 0, 128 * 4 * 4);
+ screen->constbuf = screen->pipe.buffer_create(&screen->pipe, 0, 0, 128 * 4 * 4);
if (nvws->res_init(&screen->vp_data_heap, 0, 128)) {
NOUVEAU_ERR("Error initialising constant buffer\n");
nv50_screen_destroy(&screen->pipe);
@@ -304,7 +304,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
* blocks. At some point we *may* want to go the NVIDIA way of doing
* things?
*/
- screen->tic = ws->buffer_create(ws, 0, 0, 32 * 8 * 4);
+ screen->tic = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4);
so_method(so, screen->tesla, 0x1280, 3);
so_reloc (so, screen->tic, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
@@ -318,7 +318,7 @@ nv50_screen_create(struct pipe_winsys *ws, struct nouveau_winsys *nvws)
NOUVEAU_BO_RD | NOUVEAU_BO_LOW, 0, 0);
so_data (so, 0x00000800);
- screen->tsc = ws->buffer_create(ws, 0, 0, 32 * 8 * 4);
+ screen->tsc = screen->pipe.buffer_create(&screen->pipe, 0, 0, 32 * 8 * 4);
so_method(so, screen->tesla, 0x1280, 3);
so_reloc (so, screen->tsc, 0, NOUVEAU_BO_VRAM |
NOUVEAU_BO_RD | NOUVEAU_BO_HIGH, 0, 0);
diff --git a/src/gallium/drivers/nv50/nv50_transfer.c b/src/gallium/drivers/nv50/nv50_transfer.c
index a00c999510d..747195b4f63 100644
--- a/src/gallium/drivers/nv50/nv50_transfer.c
+++ b/src/gallium/drivers/nv50/nv50_transfer.c
@@ -123,7 +123,6 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
if (!tx)
return NULL;
- tx->base.refcount = 1;
pipe_texture_reference(&tx->base.texture, pt);
tx->base.format = pt->format;
tx->base.width = w;
@@ -158,17 +157,13 @@ nv50_transfer_new(struct pipe_screen *pscreen, struct pipe_texture *pt,
}
static void
-nv50_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
+nv50_transfer_del(struct pipe_transfer *ptx)
{
- struct pipe_transfer *ptx = *pptx;
struct nv50_transfer *tx = (struct nv50_transfer *)ptx;
struct nv50_miptree *mt = nv50_miptree(ptx->texture);
- *pptx = NULL;
- if (--ptx->refcount)
- return;
-
if (ptx->usage != PIPE_TRANSFER_READ) {
+ struct pipe_screen *pscreen = ptx->texture->screen;
nv50_transfer_rect_m2mf(pscreen, tx->buffer, tx->base.stride,
0, 0, tx->base.width, tx->base.height,
mt->buffer, tx->level_pitch,
@@ -179,7 +174,7 @@ nv50_transfer_del(struct pipe_screen *pscreen, struct pipe_transfer **pptx)
NOUVEAU_BO_VRAM | NOUVEAU_BO_GART);
}
- pipe_buffer_reference(pscreen, &tx->buffer, NULL);
+ pipe_buffer_reference(&tx->buffer, NULL);
pipe_texture_reference(&ptx->texture, NULL);
FREE(ptx);
}
@@ -210,7 +205,7 @@ void
nv50_transfer_init_screen_functions(struct pipe_screen *pscreen)
{
pscreen->get_tex_transfer = nv50_transfer_new;
- pscreen->tex_transfer_release = nv50_transfer_del;
+ pscreen->tex_transfer_destroy = nv50_transfer_del;
pscreen->transfer_map = nv50_transfer_map;
pscreen->transfer_unmap = nv50_transfer_unmap;
}
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;
diff --git a/src/gallium/drivers/r300/r300_swtcl_emit.c b/src/gallium/drivers/r300/r300_swtcl_emit.c
index f9baaade1e3..01235674ac8 100644
--- a/src/gallium/drivers/r300/r300_swtcl_emit.c
+++ b/src/gallium/drivers/r300/r300_swtcl_emit.c
@@ -79,7 +79,7 @@ static boolean r300_swtcl_render_allocate_vertices(struct vbuf_render* render,
size_t size = (size_t)vertex_size * (size_t)count;
if (r300render->vbo) {
- pipe_buffer_reference(screen, &r300render->vbo, NULL);
+ pipe_buffer_reference(&r300render->vbo, NULL);
}
r300render->vbo_size = MAX2(size, r300render->vbo_alloc_size);
@@ -125,9 +125,8 @@ static void r300_swtcl_render_unmap_vertices(struct vbuf_render* render,
static void r300_swtcl_render_release_vertices(struct vbuf_render* render)
{
struct r300_swtcl_render* r300render = r300_swtcl_render(render);
- struct pipe_screen* screen = r300render->r300->context.screen;
- pipe_buffer_reference(screen, &r300render->vbo, NULL);
+ pipe_buffer_reference(&r300render->vbo, NULL);
}
static boolean r300_swtcl_render_set_primitive(struct vbuf_render* render,
diff --git a/src/gallium/drivers/r300/r300_texture.c b/src/gallium/drivers/r300/r300_texture.c
index b3425587e38..b7027553b57 100644
--- a/src/gallium/drivers/r300/r300_texture.c
+++ b/src/gallium/drivers/r300/r300_texture.c
@@ -68,7 +68,7 @@ static struct pipe_texture*
}
tex->tex = *template;
- tex->tex.refcount = 1;
+ pipe_reference_init(&tex->tex.reference, 1);
tex->tex.screen = screen;
r300_setup_miptree(tex);
@@ -85,24 +85,13 @@ static struct pipe_texture*
return (struct pipe_texture*)tex;
}
-static void r300_texture_release(struct pipe_screen* screen,
- struct pipe_texture** texture)
+static void r300_texture_destroy(struct pipe_texture* texture)
{
- if (!*texture) {
- return;
- }
-
- (*texture)->refcount--;
-
- if ((*texture)->refcount <= 0) {
- struct r300_texture* tex = (struct r300_texture*)*texture;
+ struct r300_texture* tex = (struct r300_texture*)texture;
- pipe_buffer_reference(screen, &tex->buffer, NULL);
+ pipe_buffer_reference(&tex->buffer, NULL);
- FREE(tex);
- }
-
- *texture = NULL;
+ FREE(tex);
}
static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
@@ -120,7 +109,7 @@ static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
offset = tex->offset[level];
if (surface) {
- surface->refcount = 1;
+ pipe_reference_init(&surface->reference, 1);
pipe_texture_reference(&surface->texture, texture);
surface->format = texture->format;
surface->width = texture->width[level];
@@ -133,19 +122,10 @@ static struct pipe_surface* r300_get_tex_surface(struct pipe_screen* screen,
return surface;
}
-static void r300_tex_surface_release(struct pipe_screen* screen,
- struct pipe_surface** surface)
+static void r300_tex_surface_destroy(struct pipe_surface* s)
{
- struct pipe_surface* s = *surface;
-
- s->refcount--;
-
- if (s->refcount <= 0) {
- pipe_texture_reference(&s->texture, NULL);
- FREE(s);
- }
-
- *surface = NULL;
+ pipe_texture_reference(&s->texture, NULL);
+ FREE(s);
}
static struct pipe_texture*
@@ -168,12 +148,12 @@ static struct pipe_texture*
}
tex->tex = *base;
- tex->tex.refcount = 1;
+ pipe_reference_init(&tex->tex.reference, 1);
tex->tex.screen = screen;
tex->stride = *stride;
- pipe_buffer_reference(screen, &tex->buffer, buffer);
+ pipe_buffer_reference(&tex->buffer, buffer);
return (struct pipe_texture*)tex;
}
@@ -181,9 +161,9 @@ static struct pipe_texture*
void r300_init_screen_texture_functions(struct pipe_screen* screen)
{
screen->texture_create = r300_texture_create;
- screen->texture_release = r300_texture_release;
+ screen->texture_destroy = r300_texture_destroy;
screen->get_tex_surface = r300_get_tex_surface;
- screen->tex_surface_release = r300_tex_surface_release;
+ screen->tex_surface_destroy = r300_tex_surface_destroy;
screen->texture_blanket = r300_texture_blanket;
}
@@ -196,7 +176,7 @@ boolean r300_get_texture_buffer(struct pipe_texture* texture,
return FALSE;
}
- pipe_buffer_reference(texture->screen, buffer, tex->buffer);
+ pipe_buffer_reference(buffer, tex->buffer);
if (stride) {
*stride = tex->stride;
diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c
index ff5d1b54a4c..cc552c4915b 100644
--- a/src/gallium/drivers/softpipe/sp_context.c
+++ b/src/gallium/drivers/softpipe/sp_context.c
@@ -87,7 +87,6 @@ softpipe_unmap_transfers(struct softpipe_context *sp)
static void softpipe_destroy( struct pipe_context *pipe )
{
struct softpipe_context *softpipe = softpipe_context( pipe );
- struct pipe_screen *screen = pipe->screen;
uint i;
if (softpipe->draw)
@@ -116,7 +115,7 @@ static void softpipe_destroy( struct pipe_context *pipe )
for (i = 0; i < Elements(softpipe->constants); i++) {
if (softpipe->constants[i].buffer) {
- pipe_buffer_reference(screen, &softpipe->constants[i].buffer, NULL);
+ pipe_buffer_reference(&softpipe->constants[i].buffer, NULL);
}
}
diff --git a/src/gallium/drivers/softpipe/sp_state_fs.c b/src/gallium/drivers/softpipe/sp_state_fs.c
index 4d01a9dbe15..957c8b72e48 100644
--- a/src/gallium/drivers/softpipe/sp_state_fs.c
+++ b/src/gallium/drivers/softpipe/sp_state_fs.c
@@ -146,14 +146,12 @@ softpipe_set_constant_buffer(struct pipe_context *pipe,
const struct pipe_constant_buffer *buf)
{
struct softpipe_context *softpipe = softpipe_context(pipe);
- struct pipe_screen *screen = pipe->screen;
assert(shader < PIPE_SHADER_TYPES);
assert(index == 0);
/* note: reference counting */
- pipe_buffer_reference(screen,
- &softpipe->constants[shader].buffer,
+ pipe_buffer_reference(&softpipe->constants[shader].buffer,
buf ? buf->buffer : NULL);
softpipe->dirty |= SP_NEW_CONSTANTS;
diff --git a/src/gallium/drivers/softpipe/sp_texture.c b/src/gallium/drivers/softpipe/sp_texture.c
index 142ce230fc0..4919ec826e9 100644
--- a/src/gallium/drivers/softpipe/sp_texture.c
+++ b/src/gallium/drivers/softpipe/sp_texture.c
@@ -59,7 +59,6 @@ static boolean
softpipe_texture_layout(struct pipe_screen *screen,
struct softpipe_texture * spt)
{
- struct pipe_winsys *ws = screen->winsys;
struct pipe_texture *pt = &spt->base;
unsigned level;
unsigned width = pt->width[0];
@@ -87,9 +86,9 @@ softpipe_texture_layout(struct pipe_screen *screen,
depth = minify(depth);
}
- spt->buffer = ws->buffer_create(ws, 32,
- PIPE_BUFFER_USAGE_PIXEL,
- buffer_size);
+ spt->buffer = screen->buffer_create(screen, 32,
+ PIPE_BUFFER_USAGE_PIXEL,
+ buffer_size);
return spt->buffer != NULL;
}
@@ -98,19 +97,18 @@ static boolean
softpipe_displaytarget_layout(struct pipe_screen *screen,
struct softpipe_texture * spt)
{
- struct pipe_winsys *ws = screen->winsys;
unsigned usage = (PIPE_BUFFER_USAGE_CPU_READ_WRITE |
PIPE_BUFFER_USAGE_GPU_READ_WRITE);
spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
- spt->buffer = ws->surface_buffer_create( ws,
- spt->base.width[0],
- spt->base.height[0],
- spt->base.format,
- usage,
- &spt->stride[0]);
+ spt->buffer = screen->surface_buffer_create( screen,
+ spt->base.width[0],
+ spt->base.height[0],
+ spt->base.format,
+ usage,
+ &spt->stride[0]);
return spt->buffer != NULL;
}
@@ -128,7 +126,7 @@ softpipe_texture_create(struct pipe_screen *screen,
return NULL;
spt->base = *templat;
- spt->base.refcount = 1;
+ pipe_reference_init(&spt->base.reference, 1);
spt->base.screen = screen;
if (spt->base.tex_usage & PIPE_TEXTURE_USAGE_DISPLAY_TARGET) {
@@ -140,7 +138,7 @@ softpipe_texture_create(struct pipe_screen *screen,
goto fail;
}
- assert(spt->base.refcount == 1);
+ assert(spt->base.reference.count == 1);
return &spt->base;
fail:
@@ -170,32 +168,25 @@ softpipe_texture_blanket(struct pipe_screen * screen,
return NULL;
spt->base = *base;
- spt->base.refcount = 1;
+ pipe_reference_init(&spt->base.reference, 1);
spt->base.screen = screen;
spt->base.nblocksx[0] = pf_get_nblocksx(&spt->base.block, spt->base.width[0]);
spt->base.nblocksy[0] = pf_get_nblocksy(&spt->base.block, spt->base.height[0]);
spt->stride[0] = stride[0];
- pipe_buffer_reference(screen, &spt->buffer, buffer);
+ pipe_buffer_reference(&spt->buffer, buffer);
return &spt->base;
}
static void
-softpipe_texture_release(struct pipe_screen *screen,
- struct pipe_texture **pt)
+softpipe_texture_destroy(struct pipe_texture *pt)
{
- if (!*pt)
- return;
-
- if (--(*pt)->refcount <= 0) {
- struct softpipe_texture *spt = softpipe_texture(*pt);
+ struct softpipe_texture *spt = softpipe_texture(pt);
- pipe_buffer_reference(screen, &spt->buffer, NULL);
- FREE(spt);
- }
- *pt = NULL;
+ pipe_buffer_reference(&spt->buffer, NULL);
+ FREE(spt);
}
@@ -212,7 +203,7 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
ps = CALLOC_STRUCT(pipe_surface);
if (ps) {
- ps->refcount = 1;
+ pipe_reference_init(&ps->reference, 1);
pipe_texture_reference(&ps->texture, pt);
ps->format = pt->format;
ps->width = pt->width[level];
@@ -259,20 +250,15 @@ softpipe_get_tex_surface(struct pipe_screen *screen,
static void
-softpipe_tex_surface_release(struct pipe_screen *screen,
- struct pipe_surface **s)
+softpipe_tex_surface_destroy(struct pipe_surface *surf)
{
- struct pipe_surface *surf = *s;
/* Effectively do the texture_update work here - if texture images
* needed post-processing to put them into hardware layout, this is
* where it would happen. For softpipe, nothing to do.
*/
assert(surf->texture);
- if (--surf->refcount == 0) {
- pipe_texture_reference(&surf->texture, NULL);
- FREE(surf);
- }
- *s = NULL;
+ pipe_texture_reference(&surf->texture, NULL);
+ FREE(surf);
}
@@ -292,7 +278,6 @@ softpipe_get_tex_transfer(struct pipe_screen *screen,
spt = CALLOC_STRUCT(softpipe_transfer);
if (spt) {
struct pipe_transfer *pt = &spt->base;
- pt->refcount = 1;
pipe_texture_reference(&pt->texture, texture);
pt->format = texture->format;
pt->block = texture->block;
@@ -327,20 +312,15 @@ softpipe_get_tex_transfer(struct pipe_screen *screen,
static void
-softpipe_tex_transfer_release(struct pipe_screen *screen,
- struct pipe_transfer **t)
+softpipe_tex_transfer_destroy(struct pipe_transfer *transfer)
{
- struct softpipe_transfer *transfer = softpipe_transfer(*t);
/* Effectively do the texture_update work here - if texture images
* needed post-processing to put them into hardware layout, this is
* where it would happen. For softpipe, nothing to do.
*/
- assert (transfer->base.texture);
- if (--transfer->base.refcount == 0) {
- pipe_texture_reference(&transfer->base.texture, NULL);
- FREE(transfer);
- }
- *t = NULL;
+ assert (transfer->texture);
+ pipe_texture_reference(&transfer->texture, NULL);
+ FREE(transfer);
}
@@ -408,13 +388,13 @@ softpipe_init_screen_texture_funcs(struct pipe_screen *screen)
{
screen->texture_create = softpipe_texture_create;
screen->texture_blanket = softpipe_texture_blanket;
- screen->texture_release = softpipe_texture_release;
+ screen->texture_destroy = softpipe_texture_destroy;
screen->get_tex_surface = softpipe_get_tex_surface;
- screen->tex_surface_release = softpipe_tex_surface_release;
+ screen->tex_surface_destroy = softpipe_tex_surface_destroy;
screen->get_tex_transfer = softpipe_get_tex_transfer;
- screen->tex_transfer_release = softpipe_tex_transfer_release;
+ screen->tex_transfer_destroy = softpipe_tex_transfer_destroy;
screen->transfer_map = softpipe_transfer_map;
screen->transfer_unmap = softpipe_transfer_unmap;
}
diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c
index 593360aab03..51e34d0d621 100644
--- a/src/gallium/drivers/softpipe/sp_tile_cache.c
+++ b/src/gallium/drivers/softpipe/sp_tile_cache.c
@@ -140,11 +140,11 @@ sp_destroy_tile_cache(struct softpipe_tile_cache *tc)
}
if (tc->transfer) {
screen = tc->transfer->texture->screen;
- screen->tex_transfer_release(screen, &tc->transfer);
+ screen->tex_transfer_destroy(tc->transfer);
}
if (tc->tex_trans) {
screen = tc->tex_trans->texture->screen;
- screen->tex_transfer_release(screen, &tc->tex_trans);
+ screen->tex_transfer_destroy(tc->tex_trans);
}
FREE( tc );
@@ -167,11 +167,11 @@ sp_tile_cache_set_surface(struct softpipe_tile_cache *tc,
return;
if (tc->transfer_map) {
- tc->screen->transfer_unmap(tc->screen, tc->transfer);
+ screen->transfer_unmap(screen, tc->transfer);
tc->transfer_map = NULL;
}
- screen->tex_transfer_release(screen, &tc->transfer);
+ screen->tex_transfer_destroy(tc->transfer);
}
tc->surface = ps;
@@ -249,11 +249,11 @@ sp_tile_cache_set_texture(struct pipe_context *pipe,
struct pipe_screen *screen = tc->transfer->texture->screen;
if (tc->tex_trans_map) {
- tc->screen->transfer_unmap(tc->screen, tc->tex_trans);
+ screen->transfer_unmap(screen, tc->tex_trans);
tc->tex_trans_map = NULL;
}
- screen->tex_transfer_release(screen, &tc->tex_trans);
+ screen->tex_transfer_destroy(tc->tex_trans);
}
/* mark as entries as invalid/empty */
@@ -559,7 +559,7 @@ sp_get_cached_tile_tex(struct softpipe_context *sp,
if (tc->tex_trans_map)
tc->screen->transfer_unmap(tc->screen, tc->tex_trans);
- screen->tex_transfer_release(screen, &tc->tex_trans);
+ screen->tex_transfer_destroy(tc->tex_trans);
}
tc->tex_trans = screen->get_tex_transfer(screen, tc->texture, face, level, z,
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;
diff --git a/src/gallium/drivers/trace/tr_state.c b/src/gallium/drivers/trace/tr_state.c
index 81a9e2376e0..0f175cd31ce 100644
--- a/src/gallium/drivers/trace/tr_state.c
+++ b/src/gallium/drivers/trace/tr_state.c
@@ -50,6 +50,14 @@ void trace_dump_block(const struct pipe_format_block *block)
}
+static void trace_dump_reference(const struct pipe_reference *reference)
+{
+ trace_dump_struct_begin("pipe_reference");
+ trace_dump_member(uint, reference, count);
+ trace_dump_struct_end();
+}
+
+
void trace_dump_template(const struct pipe_texture *templat)
{
if(!templat) {
@@ -397,6 +405,8 @@ void trace_dump_surface(const struct pipe_surface *state)
trace_dump_struct_begin("pipe_surface");
+ trace_dump_reference(&state->reference);
+
trace_dump_member(format, state, format);
trace_dump_member(uint, state, status);
trace_dump_member(uint, state, clear_value);
@@ -405,7 +415,6 @@ void trace_dump_surface(const struct pipe_surface *state)
trace_dump_member(uint, state, layout);
trace_dump_member(uint, state, offset);
- trace_dump_member(uint, state, refcount);
trace_dump_member(uint, state, usage);
trace_dump_member(ptr, state, texture);
@@ -437,7 +446,6 @@ void trace_dump_transfer(const struct pipe_transfer *state)
trace_dump_member(uint, state, nblocksx);
trace_dump_member(uint, state, nblocksy);
trace_dump_member(uint, state, stride);
- trace_dump_member(uint, state, refcount);
trace_dump_member(uint, state, usage);
trace_dump_member(ptr, state, texture);
diff --git a/src/gallium/drivers/trace/tr_texture.c b/src/gallium/drivers/trace/tr_texture.c
index 120ba0dd317..dc45d3dcc19 100644
--- a/src/gallium/drivers/trace/tr_texture.c
+++ b/src/gallium/drivers/trace/tr_texture.c
@@ -134,7 +134,7 @@ trace_transfer_create(struct trace_texture *tr_tex,
return &tr_trans->base;
error:
- pipe_transfer_reference(&transfer, NULL);
+ transfer->texture->screen->tex_transfer_destroy(transfer);
return NULL;
}
@@ -145,7 +145,7 @@ trace_transfer_destroy(struct trace_texture *tr_tex,
{
struct trace_transfer *tr_trans = trace_transfer(tr_tex, transfer);
pipe_texture_reference(&tr_trans->base.texture, NULL);
- pipe_transfer_reference(&tr_trans->transfer, NULL);
+ transfer->texture->screen->tex_transfer_destroy(tr_trans->transfer);
FREE(tr_trans);
}
diff --git a/src/gallium/drivers/trace/tr_winsys.c b/src/gallium/drivers/trace/tr_winsys.c
index c4148fe8104..86420bbf22a 100644
--- a/src/gallium/drivers/trace/tr_winsys.c
+++ b/src/gallium/drivers/trace/tr_winsys.c
@@ -295,18 +295,16 @@ trace_winsys_buffer_unmap(struct pipe_winsys *_winsys,
static void
-trace_winsys_buffer_destroy(struct pipe_winsys *_winsys,
- struct pipe_buffer *buffer)
+trace_winsys_buffer_destroy(struct pipe_buffer *buffer)
{
- struct trace_winsys *tr_ws = trace_winsys(_winsys);
- struct pipe_winsys *winsys = tr_ws->winsys;
+ struct pipe_winsys *winsys = buffer->screen->winsys;
trace_dump_call_begin("pipe_winsys", "buffer_destroy");
trace_dump_arg(ptr, winsys);
trace_dump_arg(ptr, buffer);
- winsys->buffer_destroy(winsys, buffer);
+ winsys->buffer_destroy(buffer);
trace_dump_call_end();
}