i915g: Do propper references of surfaces in context
authorJakob Bornecrantz <wallbraker@gmail.com>
Tue, 22 Sep 2009 17:55:41 +0000 (10:55 -0700)
committerJakob Bornecrantz <wallbraker@gmail.com>
Tue, 22 Sep 2009 18:06:56 +0000 (11:06 -0700)
src/gallium/drivers/i915simple/i915_context.c
src/gallium/drivers/i915simple/i915_state.c

index b43f7352456d510ddfbad007c2387974150bd4b4..e745f3342d1b345d5b0636efcd71d83603d276c6 100644 (file)
@@ -175,12 +175,19 @@ i915_is_buffer_referenced(struct pipe_context *pipe,
 static void i915_destroy(struct pipe_context *pipe)
 {
    struct i915_context *i915 = i915_context(pipe);
+   int i;
 
    draw_destroy(i915->draw);
    
    if(i915->batch)
       i915->iws->batchbuffer_destroy(i915->batch);
 
+   /* unbind framebuffer */
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+      pipe_surface_reference(&i915->framebuffer.cbufs[i], NULL);
+   }
+   pipe_surface_reference(&i915->framebuffer.zsbuf, NULL);
+
    FREE(i915);
 }
 
index 0087dfa410f881a7fa6ce3b86a664afd26f04e8e..7d48e6e84d58a00c795d9699db05e43ce3d31fdc 100644 (file)
@@ -588,9 +588,17 @@ static void i915_set_framebuffer_state(struct pipe_context *pipe,
                                       const struct pipe_framebuffer_state *fb)
 {
    struct i915_context *i915 = i915_context(pipe);
+   int i;
+
    draw_flush(i915->draw);
 
-   i915->framebuffer = *fb; /* struct copy */
+   i915->framebuffer.width = fb->width;
+   i915->framebuffer.height = fb->height;
+   i915->framebuffer.nr_cbufs = fb->nr_cbufs;
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
+      pipe_surface_reference(&i915->framebuffer.cbufs[i], fb->cbufs[i]);
+   }
+   pipe_surface_reference(&i915->framebuffer.zsbuf, fb->zsbuf);
 
    i915->dirty |= I915_NEW_FRAMEBUFFER;
 }