From fbddc75aa2f6542117783b8024f9ebd2f0309e1f Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Sep 2009 08:21:54 -0600 Subject: softpipe: Grab a ref when the fb is set. 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 | 9 +++++++-- src/gallium/drivers/softpipe/sp_state_surface.c | 4 ++-- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 86df320ea8..b4650c0dc5 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -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) { diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c index 7c06d864a7..181bff8f75 100644 --- a/src/gallium/drivers/softpipe/sp_state_surface.c +++ b/src/gallium/drivers/softpipe/sp_state_surface.c @@ -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); -- cgit v1.2.3 From 564df9dc5f6335eb8dc68f3c69cf054d2142663c Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 29 Sep 2009 08:50:56 -0600 Subject: softpipe: initialize the clear_flags bitvector in sp_create_tile_cache() This silences tons of valgrind warnings in programs that don't call glClear(), such as progs/demos/gamma. --- src/gallium/drivers/softpipe/sp_tile_cache.c | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'src/gallium') diff --git a/src/gallium/drivers/softpipe/sp_tile_cache.c b/src/gallium/drivers/softpipe/sp_tile_cache.c index 461cbb9f95..5f7864e671 100644 --- a/src/gallium/drivers/softpipe/sp_tile_cache.c +++ b/src/gallium/drivers/softpipe/sp_tile_cache.c @@ -130,6 +130,11 @@ sp_create_tile_cache( struct pipe_screen *screen ) tc->entries[pos].x = tc->entries[pos].y = -1; } + +#if TILE_CLEAR_OPTIMIZATION + /* set flags to indicate all the tiles are cleared */ + memset(tc->clear_flags, 255, sizeof(tc->clear_flags)); +#endif } return tc; } -- cgit v1.2.3