From 5d0cf9ebb41c05b0c6fa6914ccbb1e1871e27099 Mon Sep 17 00:00:00 2001 From: José Fonseca Date: Mon, 15 Jun 2009 18:42:13 +0100 Subject: softpipe: Fix softpipe_is_texture_referenced. Render results are only visible when the render cache is flushed. softpipe_is_texture_referenced must reflect that or transfers to/from the textures bound in the framebuffer won't be proceeded of the necessary flush, causing transfer data to be outdated/clobbered. This fixes conform drawpix test with softpipe. --- src/gallium/drivers/softpipe/sp_context.c | 16 ++++++++++++++++ src/gallium/drivers/softpipe/sp_context.h | 2 ++ src/gallium/drivers/softpipe/sp_draw_arrays.c | 2 ++ src/gallium/drivers/softpipe/sp_flush.c | 2 ++ 4 files changed, 22 insertions(+) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/softpipe/sp_context.c b/src/gallium/drivers/softpipe/sp_context.c index 62e8d99cfd..86df320ea8 100644 --- a/src/gallium/drivers/softpipe/sp_context.c +++ b/src/gallium/drivers/softpipe/sp_context.c @@ -126,6 +126,22 @@ softpipe_is_texture_referenced( struct pipe_context *pipe, struct pipe_texture *texture, unsigned face, unsigned level) { + struct softpipe_context *softpipe = softpipe_context( pipe ); + unsigned i; + + if(softpipe->dirty_render_cache) { + for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++) { + if(softpipe->framebuffer.cbufs[i] && + softpipe->framebuffer.cbufs[i]->texture == texture) + return PIPE_REFERENCED_FOR_WRITE; + } + if(softpipe->framebuffer.zsbuf && + softpipe->framebuffer.zsbuf->texture == texture) + return PIPE_REFERENCED_FOR_WRITE; + } + + /* FIXME: we also need to do the same for the texture cache */ + return PIPE_UNREFERENCED; } diff --git a/src/gallium/drivers/softpipe/sp_context.h b/src/gallium/drivers/softpipe/sp_context.h index 59d6df8f2d..dffc15a4f1 100644 --- a/src/gallium/drivers/softpipe/sp_context.h +++ b/src/gallium/drivers/softpipe/sp_context.h @@ -144,6 +144,8 @@ struct softpipe_context { struct draw_stage *vbuf; struct softpipe_vbuf_render *vbuf_render; + boolean dirty_render_cache; + struct softpipe_tile_cache *cbuf_cache[PIPE_MAX_COLOR_BUFS]; struct softpipe_tile_cache *zsbuf_cache; diff --git a/src/gallium/drivers/softpipe/sp_draw_arrays.c b/src/gallium/drivers/softpipe/sp_draw_arrays.c index f117096bf7..ba2766ff13 100644 --- a/src/gallium/drivers/softpipe/sp_draw_arrays.c +++ b/src/gallium/drivers/softpipe/sp_draw_arrays.c @@ -182,6 +182,8 @@ softpipe_draw_range_elements(struct pipe_context *pipe, /* Note: leave drawing surfaces mapped */ softpipe_unmap_constant_buffers(sp); + sp->dirty_render_cache = TRUE; + return TRUE; } diff --git a/src/gallium/drivers/softpipe/sp_flush.c b/src/gallium/drivers/softpipe/sp_flush.c index 035f4b963e..4a14d49686 100644 --- a/src/gallium/drivers/softpipe/sp_flush.c +++ b/src/gallium/drivers/softpipe/sp_flush.c @@ -71,6 +71,8 @@ softpipe_flush( struct pipe_context *pipe, * to unmap surfaces when flushing. */ softpipe_unmap_transfers(softpipe); + + softpipe->dirty_render_cache = FALSE; } /* Enable to dump BMPs of the color/depth buffers each frame */ -- cgit v1.2.3 From 742ba084068b6856e94283a9c5fe3b39d48f64cb Mon Sep 17 00:00:00 2001 From: Brian Paul Date: Tue, 16 Jun 2009 15:41:49 -0600 Subject: softpipe: fix out of bounds quad rasterization bug For some triangles we can generate quads which lie just outside the surface bounds. Just check the quad's mask before trying to emit/process the quad. Fixes failed assertion in Lightsmark. --- src/gallium/drivers/softpipe/sp_setup.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) (limited to 'src/gallium/drivers') diff --git a/src/gallium/drivers/softpipe/sp_setup.c b/src/gallium/drivers/softpipe/sp_setup.c index accc692b66..e5be65242d 100644 --- a/src/gallium/drivers/softpipe/sp_setup.c +++ b/src/gallium/drivers/softpipe/sp_setup.c @@ -444,7 +444,8 @@ static void flush_spans( struct setup_context *setup ) mask |= MASK_TOP_RIGHT; if (x+1 >= xleft1 && x+1 < xright1) mask |= MASK_BOTTOM_RIGHT; - EMIT_QUAD( setup, x, setup->span.y, mask ); + if (mask) + EMIT_QUAD( setup, x, setup->span.y, mask ); } break; @@ -458,7 +459,8 @@ static void flush_spans( struct setup_context *setup ) mask |= MASK_TOP_LEFT; if (x+1 >= xleft0 && x+1 < xright0) mask |= MASK_TOP_RIGHT; - EMIT_QUAD( setup, x, setup->span.y, mask ); + if (mask) + EMIT_QUAD( setup, x, setup->span.y, mask ); } break; @@ -472,7 +474,8 @@ static void flush_spans( struct setup_context *setup ) mask |= MASK_BOTTOM_LEFT; if (x+1 >= xleft1 && x+1 < xright1) mask |= MASK_BOTTOM_RIGHT; - EMIT_QUAD( setup, x, setup->span.y, mask ); + if (mask) + EMIT_QUAD( setup, x, setup->span.y, mask ); } break; -- cgit v1.2.3