softpipe: Fix softpipe_is_texture_referenced.
authorJosé Fonseca <jfonseca@vmware.com>
Mon, 15 Jun 2009 17:42:13 +0000 (18:42 +0100)
committerJosé Fonseca <jfonseca@vmware.com>
Mon, 15 Jun 2009 17:42:13 +0000 (18:42 +0100)
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
src/gallium/drivers/softpipe/sp_context.h
src/gallium/drivers/softpipe/sp_draw_arrays.c
src/gallium/drivers/softpipe/sp_flush.c

index 62e8d99cfd0300c332bfe2af6a53833fdb1bb69b..86df320ea8ab93580705ccd51b616cf9776ac2ee 100644 (file)
@@ -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;
 }
 
index 59d6df8f2dd901e49059f25ccb999efe7473e143..dffc15a4f1991ae72e0eab836bd21ca99695c32c 100644 (file)
@@ -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;
 
index f117096bf733d71e7e8bbce0f7d29889d0ce36a6..ba2766ff139636e3f5f1faf8c185c6f21db85f22 100644 (file)
@@ -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;
 }
 
index 035f4b963eb37426ceab9501654616d5129f8d05..4a14d49686e6e56d1ec8ae179dc986cd9987199e 100644 (file)
@@ -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 */