nv50,nvc0: hold references to the framebuffer surfaces
authorChristoph Bumiller <e0425955@student.tuwien.ac.at>
Wed, 7 Mar 2012 18:44:10 +0000 (19:44 +0100)
committerChristoph Bumiller <e0425955@student.tuwien.ac.at>
Sat, 14 Apr 2012 04:14:21 +0000 (06:14 +0200)
src/gallium/drivers/nv50/nv50_context.c
src/gallium/drivers/nv50/nv50_state.c
src/gallium/drivers/nvc0/nvc0_context.c
src/gallium/drivers/nvc0/nvc0_state.c

index 98f8c4d266cc55d40dd3fbb74ce559e1671e4466..96ada551b308ad288220ed444ef8326a63a66544 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "draw/draw_context.h"
 #include "pipe/p_defines.h"
+#include "util/u_framebuffer.h"
 
 #include "nv50_context.h"
 #include "nv50_screen.h"
@@ -71,6 +72,8 @@ nv50_context_unreference_resources(struct nv50_context *nv50)
    nouveau_bufctx_del(&nv50->bufctx_3d);
    nouveau_bufctx_del(&nv50->bufctx);
 
+   util_unreference_framebuffer_state(&nv50->framebuffer);
+
    for (i = 0; i < nv50->num_vtxbufs; ++i)
       pipe_resource_reference(&nv50->vtxbuf[i].buffer, NULL);
 
index e1e1af039bb1ae9ef15f605503b734ac71381d43..bf554427ca0d59a1a2f6cfa7e5622785b0bf06e5 100644 (file)
@@ -803,10 +803,22 @@ nv50_set_framebuffer_state(struct pipe_context *pipe,
                            const struct pipe_framebuffer_state *fb)
 {
    struct nv50_context *nv50 = nv50_context(pipe);
+   unsigned i;
 
    nouveau_bufctx_reset(nv50->bufctx_3d, NV50_BIND_FB);
 
-   nv50->framebuffer = *fb;
+   for (i = 0; i < fb->nr_cbufs; ++i)
+      pipe_surface_reference(&nv50->framebuffer.cbufs[i], fb->cbufs[i]);
+   for (; i < nv50->framebuffer.nr_cbufs; ++i)
+      pipe_surface_reference(&nv50->framebuffer.cbufs[i], NULL);
+
+   nv50->framebuffer.nr_cbufs = fb->nr_cbufs;
+
+   nv50->framebuffer.width = fb->width;
+   nv50->framebuffer.height = fb->height;
+
+   pipe_surface_reference(&nv50->framebuffer.zsbuf, fb->zsbuf);
+
    nv50->dirty |= NV50_NEW_FRAMEBUFFER;
 }
 
index dcdc830c408d57a52a54477949d0292355e1c8e8..471c7be77e0fe4fd1c2aa5b694c35cffe92a2c49 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "draw/draw_context.h"
 #include "pipe/p_defines.h"
+#include "util/u_framebuffer.h"
 
 #include "nvc0_context.h"
 #include "nvc0_screen.h"
@@ -57,6 +58,8 @@ nvc0_context_unreference_resources(struct nvc0_context *nvc0)
    nouveau_bufctx_del(&nvc0->bufctx_3d);
    nouveau_bufctx_del(&nvc0->bufctx);
 
+   util_unreference_framebuffer_state(&nvc0->framebuffer);
+
    for (i = 0; i < nvc0->num_vtxbufs; ++i)
       pipe_resource_reference(&nvc0->vtxbuf[i].buffer, NULL);
 
index e349491b66e1bf348253d2287a3d710a47ccbbba..b2cd54af129440a948af136fabc571a68a323ca2 100644 (file)
@@ -679,10 +679,22 @@ nvc0_set_framebuffer_state(struct pipe_context *pipe,
                            const struct pipe_framebuffer_state *fb)
 {
     struct nvc0_context *nvc0 = nvc0_context(pipe);
+    unsigned i;
 
     nouveau_bufctx_reset(nvc0->bufctx_3d, NVC0_BIND_FB);
 
-    nvc0->framebuffer = *fb;
+    for (i = 0; i < fb->nr_cbufs; ++i)
+       pipe_surface_reference(&nvc0->framebuffer.cbufs[i], fb->cbufs[i]);
+    for (; i < nvc0->framebuffer.nr_cbufs; ++i)
+       pipe_surface_reference(&nvc0->framebuffer.cbufs[i], NULL);
+
+    nvc0->framebuffer.nr_cbufs = fb->nr_cbufs;
+
+    nvc0->framebuffer.width = fb->width;
+    nvc0->framebuffer.height = fb->height;
+
+    pipe_surface_reference(&nvc0->framebuffer.zsbuf, fb->zsbuf);
+
     nvc0->dirty |= NVC0_NEW_FRAMEBUFFER;
 }