From: Marek Olšák Date: Wed, 12 Sep 2012 22:46:54 +0000 (+0200) Subject: softpipe: fix set_framebuffer_state with uninitialized surfaces past nr_cbufs-1 X-Git-Url: https://git.libre-soc.org/?a=commitdiff_plain;h=c15dbd7ef2d60bcab3d1914f8e19fde3e966694e;p=mesa.git softpipe: fix set_framebuffer_state with uninitialized surfaces past nr_cbufs-1 Tested-by: Michel Dänzer Reviewed-by: Brian Paul --- 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); } }