From c15dbd7ef2d60bcab3d1914f8e19fde3e966694e Mon Sep 17 00:00:00 2001 From: Marek Olšák Date: Thu, 13 Sep 2012 00:46:54 +0200 Subject: softpipe: fix set_framebuffer_state with uninitialized surfaces past nr_cbufs-1 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Tested-by: Michel Dänzer Reviewed-by: Brian Paul --- src/gallium/drivers/softpipe/sp_state_surface.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/softpipe/sp_state_surface.c b/src/gallium/drivers/softpipe/sp_state_surface.c index 2db6faeca46..c0bd1f757e1 100644 --- a/src/gallium/drivers/softpipe/sp_state_surface.c +++ b/src/gallium/drivers/softpipe/sp_state_surface.c @@ -54,16 +54,18 @@ softpipe_set_framebuffer_state(struct pipe_context *pipe, draw_flush(sp->draw); for (i = 0; i < PIPE_MAX_COLOR_BUFS; i++) { + struct pipe_surface *cb = i < fb->nr_cbufs ? fb->cbufs[i] : NULL; + /* check if changing cbuf */ - if (sp->framebuffer.cbufs[i] != fb->cbufs[i]) { + if (sp->framebuffer.cbufs[i] != cb) { /* flush old */ sp_flush_tile_cache(sp->cbuf_cache[i]); /* assign new */ - pipe_surface_reference(&sp->framebuffer.cbufs[i], fb->cbufs[i]); + pipe_surface_reference(&sp->framebuffer.cbufs[i], cb); /* update cache */ - sp_tile_cache_set_surface(sp->cbuf_cache[i], fb->cbufs[i]); + sp_tile_cache_set_surface(sp->cbuf_cache[i], cb); } } -- cgit v1.2.3