All of lore.kernel.org
 help / color / mirror / Atom feed
* Clean up of nv40_context->state.hw and nv40_screen->state
@ 2009-12-21  7:34 Krzysztof Smiechowicz
       [not found] ` <4B2F251B.5070807-5tc4TXWwyLM@public.gmane.org>
  0 siblings, 1 reply; 2+ messages in thread
From: Krzysztof Smiechowicz @ 2009-12-21  7:34 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Hi,

I'm trying to find a place where objects held in 
nv40_context->state.hw[] and nv40_screen->state[] are being unreferenced 
during pipe_context destruction.

Currently I'm observing that these objects are not unreferenced and 
since they hold reference to buffer objects, the buffer objects 
themselves are not unreferenced as well (for example color buffer or z 
buffer).

In order to clean those references I applied the following changes:

Index: nv40_screen.c
===================================================================
--- nv40_screen.c	(wersja 32083)
+++ 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_context.c
===================================================================
--- nv40_context.c	(wersja 32083)
+++ 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);


Is this the correct approach or did I miss where those objects are 
unreferenced?

Best regards,
Krzysztof

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

* Re: Clean up of nv40_context->state.hw and nv40_screen->state
       [not found] ` <4B2F251B.5070807-5tc4TXWwyLM@public.gmane.org>
@ 2009-12-21  9:57   ` Krzysztof Smiechowicz
  0 siblings, 0 replies; 2+ messages in thread
From: Krzysztof Smiechowicz @ 2009-12-21  9:57 UTC (permalink / raw)
  To: nouveau-PD4FTy7X32lNgt0PjOBp9y5qC8QIuHrW

Krzysztof Smiechowicz pisze:
> Hi,
> 
> I'm trying to find a place where objects held in 
> nv40_context->state.hw[] and nv40_screen->state[] are being unreferenced 
> during pipe_context destruction.
> 
> Currently I'm observing that these objects are not unreferenced and 
> since they hold reference to buffer objects, the buffer objects 
> themselves are not unreferenced as well (for example color buffer or z 
> buffer).
> 
> In order to clean those references I applied the following changes:
> 
> Index: nv40_screen.c
> ===================================================================
> --- nv40_screen.c	(wersja 32083)
> +++ 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_context.c
> ===================================================================
> --- nv40_context.c	(wersja 32083)
> +++ 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);
> 
> 
> Is this the correct approach or did I miss where those objects are 
> unreferenced?
> 

A similar patch for nv40_fragprog:

Index: nv40_fragprog.c
===================================================================
--- nv40_fragprog.c	(wersja 32083)
+++ 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);
  }

If this is the right direction, I can prepare a cumulative patch for 
nv30, nv40 and nv50.

Best regards,
Krzysztof

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

end of thread, other threads:[~2009-12-21  9:57 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2009-12-21  7:34 Clean up of nv40_context->state.hw and nv40_screen->state Krzysztof Smiechowicz
     [not found] ` <4B2F251B.5070807-5tc4TXWwyLM@public.gmane.org>
2009-12-21  9:57   ` Krzysztof Smiechowicz

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.