All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH 1/2] Unreference state/buffer objects on context/screen destruction
@ 2009-12-21 14:11 Krzysztof Smiechowicz
       [not found] ` <4B2F81F6.1010105-5tc4TXWwyLM@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Smiechowicz @ 2009-12-21 14:11 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

- unreference state objects so that buffer objects are unreferenced and 
eventually destroyed
- free channel at screen's destruction

Index: nv50/nv50_screen.c
===================================================================
--- nv50/nv50_screen.c	(wersja 32083)
+++ nv50/nv50_screen.c	(kopia robocza)
@@ -162,7 +162,22 @@
  nv50_screen_destroy(struct pipe_screen *pscreen)
  {
  	struct nv50_screen *screen = nv50_screen(pscreen);
+    unsigned i;

+    for (i = 0; i < 2; i++) {
+        if (screen->constbuf_parm[i])
+            nouveau_bo_ref(NULL, &screen->constbuf_parm[i]);
+    }
+
+    if (screen->constbuf_misc[0])
+        nouveau_bo_ref(NULL, &screen->constbuf_misc[0]);
+    if (screen->tic)
+        nouveau_bo_ref(NULL, &screen->tic);
+    if (screen->tsc)
+        nouveau_bo_ref(NULL, &screen->tsc);
+    if (screen->static_init)
+        so_ref(NULL, &screen->static_init);
+
  	nouveau_notifier_free(&screen->sync);
  	nouveau_grobj_free(&screen->tesla);
  	nouveau_grobj_free(&screen->eng2d);
Index: nv50/nv50_context.c
===================================================================
--- nv50/nv50_context.c	(wersja 32083)
+++ nv50/nv50_context.c	(kopia robocza)
@@ -43,6 +43,39 @@
  {
  	struct nv50_context *nv50 = nv50_context(pipe);

+	if (nv50->state.fb)
+	    so_ref(NULL, &nv50->state.fb);
+	if (nv50->state.blend)
+	    so_ref(NULL, &nv50->state.blend);
+	if (nv50->state.blend_colour)
+	    so_ref(NULL, &nv50->state.blend_colour);
+	if (nv50->state.zsa)
+	    so_ref(NULL, &nv50->state.zsa);
+	if (nv50->state.rast)
+	    so_ref(NULL, &nv50->state.rast);
+	if (nv50->state.stipple)
+	    so_ref(NULL, &nv50->state.stipple);
+	if (nv50->state.scissor)
+	    so_ref(NULL, &nv50->state.scissor);
+	if (nv50->state.viewport)
+	    so_ref(NULL, &nv50->state.viewport);
+	if (nv50->state.tsc_upload)
+	    so_ref(NULL, &nv50->state.tsc_upload);
+	if (nv50->state.tic_upload)
+	    so_ref(NULL, &nv50->state.tic_upload);
+	if (nv50->state.vertprog)
+	    so_ref(NULL, &nv50->state.vertprog);
+	if (nv50->state.fragprog)
+	    so_ref(NULL, &nv50->state.fragprog);
+	if (nv50->state.programs)
+	    so_ref(NULL, &nv50->state.programs);
+	if (nv50->state.vtxfmt)
+	    so_ref(NULL, &nv50->state.vtxfmt);
+	if (nv50->state.vtxbuf)
+	    so_ref(NULL, &nv50->state.vtxbuf);
+	if (nv50->state.vtxattr)
+	    so_ref(NULL, &nv50->state.vtxattr);
+
  	draw_destroy(nv50->draw);
  	FREE(nv50);
  }
Index: nv40/nv40_screen.c
===================================================================
--- nv40/nv40_screen.c	(wersja 32083)
+++ nv40/nv40_screen.c	(kopia robocza)
@@ -140,7 +140,13 @@
  nv40_screen_destroy(struct pipe_screen *pscreen)
  {
  	struct nv40_screen *screen = nv40_screen(pscreen);
+    unsigned i;

+    for (i = 0; i < NV40_STATE_MAX; i++) {
+        if (screen->state[i])
+            so_ref(NULL, &screen->state[i]);
+    }
+
  	nouveau_resource_free(&screen->vp_exec_heap);
  	nouveau_resource_free(&screen->vp_data_heap);
  	nouveau_resource_free(&screen->query_heap);
Index: nv40/nv40_fragprog.c
===================================================================
--- nv40/nv40_fragprog.c	(wersja 32083)
+++ nv40/nv40_fragprog.c	(kopia robocza)
@@ -948,6 +948,12 @@
  nv40_fragprog_destroy(struct nv40_context *nv40,
  		      struct nv40_fragment_program *fp)
  {
+    if (fp->buffer)
+        pipe_buffer_reference(&fp->buffer, NULL);
+
+    if (fp->so)
+        so_ref(NULL, &fp->so);
+
  	if (fp->insn_len)
  		FREE(fp->insn);
  }
Index: nv40/nv40_context.c
===================================================================
--- nv40/nv40_context.c	(wersja 32083)
+++ nv40/nv40_context.c	(kopia robocza)
@@ -25,7 +25,13 @@
  nv40_destroy(struct pipe_context *pipe)
  {
  	struct nv40_context *nv40 = nv40_context(pipe);
+    unsigned i;

+    for (i = 0; i < NV40_STATE_MAX; i++) {
+        if (nv40->state.hw[i])
+            so_ref(NULL, &nv40->state.hw[i]);
+    }
+
  	if (nv40->draw)
  		draw_destroy(nv40->draw);
  	FREE(nv40);
Index: nv30/nv30_screen.c
===================================================================
--- nv30/nv30_screen.c	(wersja 32083)
+++ nv30/nv30_screen.c	(kopia robocza)
@@ -153,7 +153,13 @@
  nv30_screen_destroy(struct pipe_screen *pscreen)
  {
  	struct nv30_screen *screen = nv30_screen(pscreen);
+    unsigned i;

+    for (i = 0; i < NV30_STATE_MAX; i++) {
+        if (screen->state[i])
+            so_ref(NULL, &screen->state[i]);
+    }
+
  	nouveau_resource_free(&screen->vp_exec_heap);
  	nouveau_resource_free(&screen->vp_data_heap);
  	nouveau_resource_free(&screen->query_heap);
@@ -161,6 +167,8 @@
  	nouveau_notifier_free(&screen->sync);
  	nouveau_grobj_free(&screen->rankine);

+	nouveau_screen_fini(&screen->base);
+	
  	FREE(pscreen);
  }

Index: nv30/nv30_fragprog.c
===================================================================
--- nv30/nv30_fragprog.c	(wersja 32083)
+++ nv30/nv30_fragprog.c	(kopia robocza)
@@ -870,6 +870,12 @@
  nv30_fragprog_destroy(struct nv30_context *nv30,
  		      struct nv30_fragment_program *fp)
  {
+    if (fp->buffer)
+        pipe_buffer_reference(&fp->buffer, NULL);
+
+    if (fp->so)
+        so_ref(NULL, &fp->so);
+
  	if (fp->insn_len)
  		FREE(fp->insn);
  }
Index: nv30/nv30_context.c
===================================================================
--- nv30/nv30_context.c	(wersja 32083)
+++ nv30/nv30_context.c	(kopia robocza)
@@ -25,7 +25,13 @@
  nv30_destroy(struct pipe_context *pipe)
  {
  	struct nv30_context *nv30 = nv30_context(pipe);
+    unsigned i;

+    for (i = 0; i < NV30_STATE_MAX; i++) {
+        if (nv30->state.hw[i])
+            so_ref(NULL, &nv30->state.hw[i]);
+    }
+
  	if (nv30->draw)
  		draw_destroy(nv30->draw);
  	FREE(nv30);
Index: nv20/nv20_screen.c
===================================================================
--- nv20/nv20_screen.c	(wersja 32083)
+++ nv20/nv20_screen.c	(kopia robocza)
@@ -116,6 +116,8 @@
  	nouveau_notifier_free(&screen->sync);
  	nouveau_grobj_free(&screen->kelvin);

+	nouveau_screen_fini(&screen->base);
+
  	FREE(pscreen);
  }

Index: nv10/nv10_screen.c
===================================================================
--- nv10/nv10_screen.c	(wersja 32083)
+++ nv10/nv10_screen.c	(kopia robocza)
@@ -116,6 +116,8 @@
  	nouveau_notifier_free(&screen->sync);
  	nouveau_grobj_free(&screen->celsius);

+	nouveau_screen_fini(&screen->base);
+
  	FREE(pscreen);
  }

Index: nouveau/nouveau_screen.c
===================================================================
--- nouveau/nouveau_screen.c	(wersja 31964)
+++ nouveau/nouveau_screen.c	(kopia robocza)
@@ -239,5 +239,6 @@
  void
  nouveau_screen_fini(struct nouveau_screen *screen)
  {
+    nouveau_channel_free(&screen->channel);
  }

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] Unreference state/buffer objects on context/screen destruction
       [not found] ` <4B2F81F6.1010105-5tc4TXWwyLM@public.gmane.org>
@ 2009-12-24  8:23   ` Krzysztof Smiechowicz
       [not found]     ` <4B3324F2.5020206-5tc4TXWwyLM@public.gmane.org>
  0 siblings, 1 reply; 4+ messages in thread
From: Krzysztof Smiechowicz @ 2009-12-24  8:23 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hi,

Any feedback on those patches? If they are ok, please commit them as I 
don't have access to either of repositories.

Best regards,
Krzysztof


Krzysztof Smiechowicz pisze:
> - unreference state objects so that buffer objects are unreferenced and 
> eventually destroyed
> - free channel at screen's destruction
> 
> Index: nv50/nv50_screen.c
> ===================================================================
> --- nv50/nv50_screen.c	(wersja 32083)
> +++ nv50/nv50_screen.c	(kopia robocza)
> @@ -162,7 +162,22 @@
>   nv50_screen_destroy(struct pipe_screen *pscreen)
>   {
>   	struct nv50_screen *screen = nv50_screen(pscreen);
> +    unsigned i;
> 
> +    for (i = 0; i < 2; i++) {
> +        if (screen->constbuf_parm[i])
> +            nouveau_bo_ref(NULL, &screen->constbuf_parm[i]);
> +    }
> +
> +    if (screen->constbuf_misc[0])
> +        nouveau_bo_ref(NULL, &screen->constbuf_misc[0]);
> +    if (screen->tic)
> +        nouveau_bo_ref(NULL, &screen->tic);
> +    if (screen->tsc)
> +        nouveau_bo_ref(NULL, &screen->tsc);
> +    if (screen->static_init)
> +        so_ref(NULL, &screen->static_init);
> +
>   	nouveau_notifier_free(&screen->sync);
>   	nouveau_grobj_free(&screen->tesla);
>   	nouveau_grobj_free(&screen->eng2d);
> Index: nv50/nv50_context.c
> ===================================================================
> --- nv50/nv50_context.c	(wersja 32083)
> +++ nv50/nv50_context.c	(kopia robocza)
> @@ -43,6 +43,39 @@
>   {
>   	struct nv50_context *nv50 = nv50_context(pipe);
> 
> +	if (nv50->state.fb)
> +	    so_ref(NULL, &nv50->state.fb);
> +	if (nv50->state.blend)
> +	    so_ref(NULL, &nv50->state.blend);
> +	if (nv50->state.blend_colour)
> +	    so_ref(NULL, &nv50->state.blend_colour);
> +	if (nv50->state.zsa)
> +	    so_ref(NULL, &nv50->state.zsa);
> +	if (nv50->state.rast)
> +	    so_ref(NULL, &nv50->state.rast);
> +	if (nv50->state.stipple)
> +	    so_ref(NULL, &nv50->state.stipple);
> +	if (nv50->state.scissor)
> +	    so_ref(NULL, &nv50->state.scissor);
> +	if (nv50->state.viewport)
> +	    so_ref(NULL, &nv50->state.viewport);
> +	if (nv50->state.tsc_upload)
> +	    so_ref(NULL, &nv50->state.tsc_upload);
> +	if (nv50->state.tic_upload)
> +	    so_ref(NULL, &nv50->state.tic_upload);
> +	if (nv50->state.vertprog)
> +	    so_ref(NULL, &nv50->state.vertprog);
> +	if (nv50->state.fragprog)
> +	    so_ref(NULL, &nv50->state.fragprog);
> +	if (nv50->state.programs)
> +	    so_ref(NULL, &nv50->state.programs);
> +	if (nv50->state.vtxfmt)
> +	    so_ref(NULL, &nv50->state.vtxfmt);
> +	if (nv50->state.vtxbuf)
> +	    so_ref(NULL, &nv50->state.vtxbuf);
> +	if (nv50->state.vtxattr)
> +	    so_ref(NULL, &nv50->state.vtxattr);
> +
>   	draw_destroy(nv50->draw);
>   	FREE(nv50);
>   }
> Index: nv40/nv40_screen.c
> ===================================================================
> --- nv40/nv40_screen.c	(wersja 32083)
> +++ nv40/nv40_screen.c	(kopia robocza)
> @@ -140,7 +140,13 @@
>   nv40_screen_destroy(struct pipe_screen *pscreen)
>   {
>   	struct nv40_screen *screen = nv40_screen(pscreen);
> +    unsigned i;
> 
> +    for (i = 0; i < NV40_STATE_MAX; i++) {
> +        if (screen->state[i])
> +            so_ref(NULL, &screen->state[i]);
> +    }
> +
>   	nouveau_resource_free(&screen->vp_exec_heap);
>   	nouveau_resource_free(&screen->vp_data_heap);
>   	nouveau_resource_free(&screen->query_heap);
> Index: nv40/nv40_fragprog.c
> ===================================================================
> --- nv40/nv40_fragprog.c	(wersja 32083)
> +++ nv40/nv40_fragprog.c	(kopia robocza)
> @@ -948,6 +948,12 @@
>   nv40_fragprog_destroy(struct nv40_context *nv40,
>   		      struct nv40_fragment_program *fp)
>   {
> +    if (fp->buffer)
> +        pipe_buffer_reference(&fp->buffer, NULL);
> +
> +    if (fp->so)
> +        so_ref(NULL, &fp->so);
> +
>   	if (fp->insn_len)
>   		FREE(fp->insn);
>   }
> Index: nv40/nv40_context.c
> ===================================================================
> --- nv40/nv40_context.c	(wersja 32083)
> +++ nv40/nv40_context.c	(kopia robocza)
> @@ -25,7 +25,13 @@
>   nv40_destroy(struct pipe_context *pipe)
>   {
>   	struct nv40_context *nv40 = nv40_context(pipe);
> +    unsigned i;
> 
> +    for (i = 0; i < NV40_STATE_MAX; i++) {
> +        if (nv40->state.hw[i])
> +            so_ref(NULL, &nv40->state.hw[i]);
> +    }
> +
>   	if (nv40->draw)
>   		draw_destroy(nv40->draw);
>   	FREE(nv40);
> Index: nv30/nv30_screen.c
> ===================================================================
> --- nv30/nv30_screen.c	(wersja 32083)
> +++ nv30/nv30_screen.c	(kopia robocza)
> @@ -153,7 +153,13 @@
>   nv30_screen_destroy(struct pipe_screen *pscreen)
>   {
>   	struct nv30_screen *screen = nv30_screen(pscreen);
> +    unsigned i;
> 
> +    for (i = 0; i < NV30_STATE_MAX; i++) {
> +        if (screen->state[i])
> +            so_ref(NULL, &screen->state[i]);
> +    }
> +
>   	nouveau_resource_free(&screen->vp_exec_heap);
>   	nouveau_resource_free(&screen->vp_data_heap);
>   	nouveau_resource_free(&screen->query_heap);
> @@ -161,6 +167,8 @@
>   	nouveau_notifier_free(&screen->sync);
>   	nouveau_grobj_free(&screen->rankine);
> 
> +	nouveau_screen_fini(&screen->base);
> +	
>   	FREE(pscreen);
>   }
> 
> Index: nv30/nv30_fragprog.c
> ===================================================================
> --- nv30/nv30_fragprog.c	(wersja 32083)
> +++ nv30/nv30_fragprog.c	(kopia robocza)
> @@ -870,6 +870,12 @@
>   nv30_fragprog_destroy(struct nv30_context *nv30,
>   		      struct nv30_fragment_program *fp)
>   {
> +    if (fp->buffer)
> +        pipe_buffer_reference(&fp->buffer, NULL);
> +
> +    if (fp->so)
> +        so_ref(NULL, &fp->so);
> +
>   	if (fp->insn_len)
>   		FREE(fp->insn);
>   }
> Index: nv30/nv30_context.c
> ===================================================================
> --- nv30/nv30_context.c	(wersja 32083)
> +++ nv30/nv30_context.c	(kopia robocza)
> @@ -25,7 +25,13 @@
>   nv30_destroy(struct pipe_context *pipe)
>   {
>   	struct nv30_context *nv30 = nv30_context(pipe);
> +    unsigned i;
> 
> +    for (i = 0; i < NV30_STATE_MAX; i++) {
> +        if (nv30->state.hw[i])
> +            so_ref(NULL, &nv30->state.hw[i]);
> +    }
> +
>   	if (nv30->draw)
>   		draw_destroy(nv30->draw);
>   	FREE(nv30);
> Index: nv20/nv20_screen.c
> ===================================================================
> --- nv20/nv20_screen.c	(wersja 32083)
> +++ nv20/nv20_screen.c	(kopia robocza)
> @@ -116,6 +116,8 @@
>   	nouveau_notifier_free(&screen->sync);
>   	nouveau_grobj_free(&screen->kelvin);
> 
> +	nouveau_screen_fini(&screen->base);
> +
>   	FREE(pscreen);
>   }
> 
> Index: nv10/nv10_screen.c
> ===================================================================
> --- nv10/nv10_screen.c	(wersja 32083)
> +++ nv10/nv10_screen.c	(kopia robocza)
> @@ -116,6 +116,8 @@
>   	nouveau_notifier_free(&screen->sync);
>   	nouveau_grobj_free(&screen->celsius);
> 
> +	nouveau_screen_fini(&screen->base);
> +
>   	FREE(pscreen);
>   }
> 
> Index: nouveau/nouveau_screen.c
> ===================================================================
> --- nouveau/nouveau_screen.c	(wersja 31964)
> +++ nouveau/nouveau_screen.c	(kopia robocza)
> @@ -239,5 +239,6 @@
>   void
>   nouveau_screen_fini(struct nouveau_screen *screen)
>   {
> +    nouveau_channel_free(&screen->channel);
>   }
> 
> _______________________________________________
> Nouveau mailing list
> Nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW@public.gmane.org
> http://lists.freedesktop.org/mailman/listinfo/nouveau
> 
> 

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: [PATCH 1/2] Unreference state/buffer objects on context/screen destruction
       [not found]     ` <4B3324F2.5020206-5tc4TXWwyLM@public.gmane.org>
@ 2009-12-27  1:44       ` Younes Manton
  0 siblings, 0 replies; 4+ messages in thread
From: Younes Manton @ 2009-12-27  1:44 UTC (permalink / raw)
  To: Krzysztof Smiechowicz; +Cc: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

On Thu, Dec 24, 2009 at 3:23 AM, Krzysztof Smiechowicz <deadwood-5tc4TXWwyLM@public.gmane.org> wrote:
> Hi,
>
> Any feedback on those patches? If they are ok, please commit them as I
> don't have access to either of repositories.
>
> Best regards,
> Krzysztof

HI, can you resend both patches as git patches?

^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH 1/2] Unreference state/buffer objects on context/screen destruction
@ 2009-12-27 10:02 Krzysztof Smiechowicz
  0 siblings, 0 replies; 4+ messages in thread
From: Krzysztof Smiechowicz @ 2009-12-27 10:02 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

(resending as git patch)

- unreference state objects so that buffer objects are unreferenced and
eventually destroyed
- free channel at screen's destruction

diff --git a/src/gallium/drivers/nouveau/nouveau_screen.c 
b/src/gallium/drivers/nouveau/nouveau_screen.c
index e4cf91c..be7735b 100644
--- a/src/gallium/drivers/nouveau/nouveau_screen.c
+++ b/src/gallium/drivers/nouveau/nouveau_screen.c
@@ -239,5 +239,6 @@ nouveau_screen_init(struct nouveau_screen *screen, 
struct nouveau_device *dev)
  void
  nouveau_screen_fini(struct nouveau_screen *screen)
  {
+    nouveau_channel_free(&screen->channel);
  }

diff --git a/src/gallium/drivers/nv10/nv10_screen.c 
b/src/gallium/drivers/nv10/nv10_screen.c
index ee5901e..8d4d7d7 100644
--- a/src/gallium/drivers/nv10/nv10_screen.c
+++ b/src/gallium/drivers/nv10/nv10_screen.c
@@ -116,6 +116,8 @@ nv10_screen_destroy(struct pipe_screen *pscreen)
  	nouveau_notifier_free(&screen->sync);
  	nouveau_grobj_free(&screen->celsius);

+	nouveau_screen_fini(&screen->base);
+
  	FREE(pscreen);
  }

diff --git a/src/gallium/drivers/nv20/nv20_screen.c 
b/src/gallium/drivers/nv20/nv20_screen.c
index 4eeacd1..7187f52 100644
--- a/src/gallium/drivers/nv20/nv20_screen.c
+++ b/src/gallium/drivers/nv20/nv20_screen.c
@@ -116,6 +116,8 @@ nv20_screen_destroy(struct pipe_screen *pscreen)
  	nouveau_notifier_free(&screen->sync);
  	nouveau_grobj_free(&screen->kelvin);

+	nouveau_screen_fini(&screen->base);
+
  	FREE(pscreen);
  }

diff --git a/src/gallium/drivers/nv30/nv30_context.c 
b/src/gallium/drivers/nv30/nv30_context.c
index 46a821a..4bf4d81 100644
--- a/src/gallium/drivers/nv30/nv30_context.c
+++ b/src/gallium/drivers/nv30/nv30_context.c
@@ -25,6 +25,12 @@ static void
  nv30_destroy(struct pipe_context *pipe)
  {
  	struct nv30_context *nv30 = nv30_context(pipe);
+    unsigned i;
+
+    for (i = 0; i < NV30_STATE_MAX; i++) {
+        if (nv30->state.hw[i])
+            so_ref(NULL, &nv30->state.hw[i]);
+    }

  	if (nv30->draw)
  		draw_destroy(nv30->draw);
diff --git a/src/gallium/drivers/nv30/nv30_fragprog.c 
b/src/gallium/drivers/nv30/nv30_fragprog.c
index 40965a9..bf1c314 100644
--- a/src/gallium/drivers/nv30/nv30_fragprog.c
+++ b/src/gallium/drivers/nv30/nv30_fragprog.c
@@ -870,6 +870,12 @@ void
  nv30_fragprog_destroy(struct nv30_context *nv30,
  		      struct nv30_fragment_program *fp)
  {
+    if (fp->buffer)
+        pipe_buffer_reference(&fp->buffer, NULL);
+
+    if (fp->so)
+        so_ref(NULL, &fp->so);
+
  	if (fp->insn_len)
  		FREE(fp->insn);
  }
diff --git a/src/gallium/drivers/nv30/nv30_screen.c 
b/src/gallium/drivers/nv30/nv30_screen.c
index 7cd3690..e17e1ab 100644
--- a/src/gallium/drivers/nv30/nv30_screen.c
+++ b/src/gallium/drivers/nv30/nv30_screen.c
@@ -156,6 +156,12 @@ static void
  nv30_screen_destroy(struct pipe_screen *pscreen)
  {
  	struct nv30_screen *screen = nv30_screen(pscreen);
+    unsigned i;
+
+    for (i = 0; i < NV30_STATE_MAX; i++) {
+        if (screen->state[i])
+            so_ref(NULL, &screen->state[i]);
+    }

  	nouveau_resource_free(&screen->vp_exec_heap);
  	nouveau_resource_free(&screen->vp_data_heap);
@@ -164,6 +170,8 @@ nv30_screen_destroy(struct pipe_screen *pscreen)
  	nouveau_notifier_free(&screen->sync);
  	nouveau_grobj_free(&screen->rankine);

+	nouveau_screen_fini(&screen->base);
+	
  	FREE(pscreen);
  }

diff --git a/src/gallium/drivers/nv40/nv40_context.c 
b/src/gallium/drivers/nv40/nv40_context.c
index eb9cce4..d668f31 100644
--- a/src/gallium/drivers/nv40/nv40_context.c
+++ b/src/gallium/drivers/nv40/nv40_context.c
@@ -25,6 +25,12 @@ static void
  nv40_destroy(struct pipe_context *pipe)
  {
  	struct nv40_context *nv40 = nv40_context(pipe);
+    unsigned i;
+
+    for (i = 0; i < NV40_STATE_MAX; i++) {
+        if (nv40->state.hw[i])
+            so_ref(NULL, &nv40->state.hw[i]);
+    }

  	if (nv40->draw)
  		draw_destroy(nv40->draw);
diff --git a/src/gallium/drivers/nv40/nv40_fragprog.c 
b/src/gallium/drivers/nv40/nv40_fragprog.c
index 1bf1672..52ba888 100644
--- a/src/gallium/drivers/nv40/nv40_fragprog.c
+++ b/src/gallium/drivers/nv40/nv40_fragprog.c
@@ -948,6 +948,12 @@ void
  nv40_fragprog_destroy(struct nv40_context *nv40,
  		      struct nv40_fragment_program *fp)
  {
+    if (fp->buffer)
+        pipe_buffer_reference(&fp->buffer, NULL);
+
+    if (fp->so)
+        so_ref(NULL, &fp->so);
+
  	if (fp->insn_len)
  		FREE(fp->insn);
  }
diff --git a/src/gallium/drivers/nv40/nv40_screen.c 
b/src/gallium/drivers/nv40/nv40_screen.c
index bd13dfd..bbe7509 100644
--- a/src/gallium/drivers/nv40/nv40_screen.c
+++ b/src/gallium/drivers/nv40/nv40_screen.c
@@ -140,6 +140,12 @@ static void
  nv40_screen_destroy(struct pipe_screen *pscreen)
  {
  	struct nv40_screen *screen = nv40_screen(pscreen);
+    unsigned i;
+
+    for (i = 0; i < NV40_STATE_MAX; i++) {
+        if (screen->state[i])
+            so_ref(NULL, &screen->state[i]);
+    }

  	nouveau_resource_free(&screen->vp_exec_heap);
  	nouveau_resource_free(&screen->vp_data_heap);
diff --git a/src/gallium/drivers/nv50/nv50_context.c 
b/src/gallium/drivers/nv50/nv50_context.c
index d21b80e..1739a4c 100644
--- a/src/gallium/drivers/nv50/nv50_context.c
+++ b/src/gallium/drivers/nv50/nv50_context.c
@@ -43,6 +43,39 @@ nv50_destroy(struct pipe_context *pipe)
  {
  	struct nv50_context *nv50 = nv50_context(pipe);

+	if (nv50->state.fb)
+	    so_ref(NULL, &nv50->state.fb);
+	if (nv50->state.blend)
+	    so_ref(NULL, &nv50->state.blend);
+	if (nv50->state.blend_colour)
+	    so_ref(NULL, &nv50->state.blend_colour);
+	if (nv50->state.zsa)
+	    so_ref(NULL, &nv50->state.zsa);
+	if (nv50->state.rast)
+	    so_ref(NULL, &nv50->state.rast);
+	if (nv50->state.stipple)
+	    so_ref(NULL, &nv50->state.stipple);
+	if (nv50->state.scissor)
+	    so_ref(NULL, &nv50->state.scissor);
+	if (nv50->state.viewport)
+	    so_ref(NULL, &nv50->state.viewport);
+	if (nv50->state.tsc_upload)
+	    so_ref(NULL, &nv50->state.tsc_upload);
+	if (nv50->state.tic_upload)
+	    so_ref(NULL, &nv50->state.tic_upload);
+	if (nv50->state.vertprog)
+	    so_ref(NULL, &nv50->state.vertprog);
+	if (nv50->state.fragprog)
+	    so_ref(NULL, &nv50->state.fragprog);
+	if (nv50->state.programs)
+	    so_ref(NULL, &nv50->state.programs);
+	if (nv50->state.vtxfmt)
+	    so_ref(NULL, &nv50->state.vtxfmt);
+	if (nv50->state.vtxbuf)
+	    so_ref(NULL, &nv50->state.vtxbuf);
+	if (nv50->state.vtxattr)
+	    so_ref(NULL, &nv50->state.vtxattr);
+
  	draw_destroy(nv50->draw);
  	FREE(nv50);
  }
diff --git a/src/gallium/drivers/nv50/nv50_screen.c 
b/src/gallium/drivers/nv50/nv50_screen.c
index 5a1efd3..9a74025 100644
--- a/src/gallium/drivers/nv50/nv50_screen.c
+++ b/src/gallium/drivers/nv50/nv50_screen.c
@@ -165,6 +165,21 @@ static void
  nv50_screen_destroy(struct pipe_screen *pscreen)
  {
  	struct nv50_screen *screen = nv50_screen(pscreen);
+    unsigned i;
+
+    for (i = 0; i < 2; i++) {
+        if (screen->constbuf_parm[i])
+            nouveau_bo_ref(NULL, &screen->constbuf_parm[i]);
+    }
+
+    if (screen->constbuf_misc[0])
+        nouveau_bo_ref(NULL, &screen->constbuf_misc[0]);
+    if (screen->tic)
+        nouveau_bo_ref(NULL, &screen->tic);
+    if (screen->tsc)
+        nouveau_bo_ref(NULL, &screen->tsc);
+    if (screen->static_init)
+        so_ref(NULL, &screen->static_init);

  	nouveau_notifier_free(&screen->sync);
  	nouveau_grobj_free(&screen->tesla);

^ permalink raw reply related	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2009-12-27 10:02 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-27 10:02 [PATCH 1/2] Unreference state/buffer objects on context/screen destruction Krzysztof Smiechowicz
  -- strict thread matches above, loose matches on Subject: below --
2009-12-21 14:11 Krzysztof Smiechowicz
     [not found] ` <4B2F81F6.1010105-5tc4TXWwyLM@public.gmane.org>
2009-12-24  8:23   ` Krzysztof Smiechowicz
     [not found]     ` <4B3324F2.5020206-5tc4TXWwyLM@public.gmane.org>
2009-12-27  1:44       ` Younes Manton

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.