From 26a199efac43cc0509f174ca47ad0d2b0044eee0 Mon Sep 17 00:00:00 2001 From: Christoph Bumiller Date: Sun, 13 Mar 2011 13:06:42 +0100 Subject: nv50,nvc0: add some missing resource referencing --- src/gallium/drivers/nv50/nv50_context.c | 24 ++++++++++++++++++++++++ src/gallium/drivers/nv50/nv50_state.c | 9 ++++++--- src/gallium/drivers/nvc0/nvc0_context.c | 27 +++++++++++++++++++++++++++ src/gallium/drivers/nvc0/nvc0_state.c | 11 +++++++---- 4 files changed, 64 insertions(+), 7 deletions(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/nv50/nv50_context.c b/src/gallium/drivers/nv50/nv50_context.c index c6bd0b15cb..204e9bef11 100644 --- a/src/gallium/drivers/nv50/nv50_context.c +++ b/src/gallium/drivers/nv50/nv50_context.c @@ -63,11 +63,35 @@ nv50_default_flush_notify(struct nouveau_channel *chan) nouveau_fence_next(&nv50->screen->base); } +static void +nv50_context_unreference_resources(struct nv50_context *nv50) +{ + unsigned s, i; + + for (i = 0; i < NV50_BUFCTX_COUNT; ++i) + nv50_bufctx_reset(nv50, i); + + for (i = 0; i < nv50->num_vtxbufs; ++i) + pipe_resource_reference(&nv50->vtxbuf[i].buffer, NULL); + + pipe_resource_reference(&nv50->idxbuf.buffer, NULL); + + for (s = 0; s < 3; ++s) { + for (i = 0; i < nv50->num_textures[s]; ++i) + pipe_sampler_view_reference(&nv50->textures[s][i], NULL); + + for (i = 0; i < 16; ++i) + pipe_resource_reference(&nv50->constbuf[s][i], NULL); + } +} + static void nv50_destroy(struct pipe_context *pipe) { struct nv50_context *nv50 = nv50_context(pipe); + nv50_context_unreference_resources(nv50); + draw_destroy(nv50->draw); if (nv50->screen->cur_ctx == nv50) { diff --git a/src/gallium/drivers/nv50/nv50_state.c b/src/gallium/drivers/nv50/nv50_state.c index 3c497451d8..db25715969 100644 --- a/src/gallium/drivers/nv50/nv50_state.c +++ b/src/gallium/drivers/nv50/nv50_state.c @@ -796,10 +796,13 @@ nv50_set_index_buffer(struct pipe_context *pipe, { struct nv50_context *nv50 = nv50_context(pipe); - if (ib) + if (ib) { + pipe_resource_reference(&nv50->idxbuf.buffer, ib->buffer); + memcpy(&nv50->idxbuf, ib, sizeof(nv50->idxbuf)); - else - nv50->idxbuf.buffer = NULL; + } else { + pipe_resource_reference(&nv50->idxbuf.buffer, NULL); + } } static void diff --git a/src/gallium/drivers/nvc0/nvc0_context.c b/src/gallium/drivers/nvc0/nvc0_context.c index 881d102dab..e4014b0d7c 100644 --- a/src/gallium/drivers/nvc0/nvc0_context.c +++ b/src/gallium/drivers/nvc0/nvc0_context.c @@ -56,11 +56,38 @@ nvc0_flush(struct pipe_context *pipe, FIRE_RING(chan); } +static void +nvc0_context_unreference_resources(struct nvc0_context *nvc0) +{ + unsigned s, i; + + for (i = 0; i < NVC0_BUFCTX_COUNT; ++i) + nvc0_bufctx_reset(nvc0, i); + + for (i = 0; i < nvc0->num_vtxbufs; ++i) + pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL); + + pipe_resource_reference(&nvc0->idxbuf.buffer, NULL); + + for (s = 0; s < 5; ++s) { + for (i = 0; i < nvc0->num_textures[s]; ++i) + pipe_sampler_view_reference(&nvc0->textures[s][i], NULL); + + for (i = 0; i < 16; ++i) + pipe_resource_reference(&nvc0->constbuf[s][i], NULL); + } + + for (i = 0; i < nvc0->num_tfbbufs; ++i) + pipe_resource_reference(&nvc0->tfbbuf[i], NULL); +} + static void nvc0_destroy(struct pipe_context *pipe) { struct nvc0_context *nvc0 = nvc0_context(pipe); + nvc0_context_unreference_resources(nvc0); + draw_destroy(nvc0->draw); if (nvc0->screen->cur_ctx == nvc0) { diff --git a/src/gallium/drivers/nvc0/nvc0_state.c b/src/gallium/drivers/nvc0/nvc0_state.c index 1815fe88a9..ab68abcfb5 100644 --- a/src/gallium/drivers/nvc0/nvc0_state.c +++ b/src/gallium/drivers/nvc0/nvc0_state.c @@ -708,10 +708,13 @@ nvc0_set_index_buffer(struct pipe_context *pipe, { struct nvc0_context *nvc0 = nvc0_context(pipe); - if (ib) - memcpy(&nvc0->idxbuf, ib, sizeof(nvc0->idxbuf)); - else - nvc0->idxbuf.buffer = NULL; + if (ib) { + pipe_resource_reference(&nvc0->idxbuf.buffer, ib->buffer); + + memcpy(&nvc0->idxbuf, ib, sizeof(nvc0->idxbuf)); + } else { + pipe_resource_reference(&nvc0->idxbuf.buffer, NULL); + } } static void -- cgit v1.2.3