softpipe: Grab a ref when the fb is set.
authorBrian Paul <brianp@vmware.com>
Tue, 29 Sep 2009 14:21:54 +0000 (08:21 -0600)
committerBrian Paul <brianp@vmware.com>
Tue, 29 Sep 2009 14:21:54 +0000 (08:21 -0600)
Nasty bug when the surface is freed and another is allocated right on
top of it. The next time we set the fb state SP thinks it's the same
surface and doesn't flush, and when the flush eventually happens the
surface belongs to a completely different texture.

(cherry picked from commit a77226071f6814a53358a5d6caff685889d0e4ec)

Conflicts:
src/gallium/drivers/softpipe/sp_context.c

src/gallium/drivers/softpipe/sp_context.c
src/gallium/drivers/softpipe/sp_state_surface.c

index 86df320ea8ab93580705ccd51b616cf9776ac2ee..b4650c0dc580de3e92812d569fcaeee5db85b54d 100644 (file)
@@ -105,12 +105,17 @@ static void softpipe_destroy( struct pipe_context *pipe )
       softpipe->quad[i].output->destroy( softpipe->quad[i].output );
    }
 
-   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++)
+   for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) {
       sp_destroy_tile_cache(softpipe->cbuf_cache[i]);
+      pipe_surface_reference(&softpipe->framebuffer.cbufs[i], NULL);
+   }
    sp_destroy_tile_cache(softpipe->zsbuf_cache);
+   pipe_surface_reference(&softpipe->framebuffer.zsbuf, NULL);
 
-   for (i = 0; i < PIPE_MAX_SAMPLERS; i++)
+   for (i = 0; i < PIPE_MAX_SAMPLERS; i++) {
       sp_destroy_tile_cache(softpipe->tex_cache[i]);
+      pipe_texture_reference(&softpipe->texture[i], NULL);
+   }
 
    for (i = 0; i < Elements(softpipe->constants); i++) {
       if (softpipe->constants[i].buffer) {
index 7c06d864a75edb12c7009396a9c9847566338b48..181bff8f75c2f19ef31cfcb43d5618662d8e2a65 100644 (file)
@@ -56,7 +56,7 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
          sp_flush_tile_cache(sp, sp->cbuf_cache[i]);
 
          /* assign new */
-         sp->framebuffer.cbufs[i] = fb->cbufs[i];
+         pipe_surface_reference(&sp->framebuffer.cbufs[i], fb->cbufs[i]);
 
          /* update cache */
          sp_tile_cache_set_surface(sp->cbuf_cache[i], fb->cbufs[i]);
@@ -71,7 +71,7 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe,
       sp_flush_tile_cache(sp, sp->zsbuf_cache);
 
       /* assign new */
-      sp->framebuffer.zsbuf = fb->zsbuf;
+      pipe_surface_reference(&sp->framebuffer.zsbuf, fb->zsbuf);
 
       /* update cache */
       sp_tile_cache_set_surface(sp->zsbuf_cache, fb->zsbuf);