Merge branch 'master' into gallium-sampler-view
[mesa.git] / src / gallium / drivers / softpipe / sp_flush.c
index 035f4b963eb37426ceab9501654616d5129f8d05..38dea13c66b804145615458f949424790c6ce7c1 100644 (file)
 #include "draw/draw_context.h"
 #include "sp_flush.h"
 #include "sp_context.h"
-#include "sp_surface.h"
 #include "sp_state.h"
 #include "sp_tile_cache.h"
-#include "sp_winsys.h"
+#include "sp_tex_tile_cache.h"
 
 
 void
@@ -51,18 +50,23 @@ softpipe_flush( struct pipe_context *pipe,
    draw_flush(softpipe->draw);
 
    if (flags & PIPE_FLUSH_TEXTURE_CACHE) {
-      for (i = 0; i < softpipe->num_textures; i++) {
-         sp_flush_tile_cache(softpipe, softpipe->tex_cache[i]);
+      for (i = 0; i < softpipe->num_sampler_views; i++) {
+         sp_flush_tex_tile_cache(softpipe->tex_cache[i]);
+      }
+      for (i = 0; i < softpipe->num_vertex_sampler_views; i++) {
+         sp_flush_tex_tile_cache(softpipe->vertex_tex_cache[i]);
       }
    }
 
-   if (flags & PIPE_FLUSH_RENDER_CACHE) {
+   if (flags & PIPE_FLUSH_SWAPBUFFERS) {
+      /* If this is a swapbuffers, just flush color buffers.
+       *
+       * The zbuffer changes are not discarded, but held in the cache
+       * in the hope that a later clear will wipe them out.
+       */
       for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++)
          if (softpipe->cbuf_cache[i])
-            sp_flush_tile_cache(softpipe, softpipe->cbuf_cache[i]);
-
-      if (softpipe->zsbuf_cache)
-         sp_flush_tile_cache(softpipe, softpipe->zsbuf_cache);
+            sp_flush_tile_cache(softpipe->cbuf_cache[i]);
 
       /* Need this call for hardware buffers before swapbuffers.
        *
@@ -72,6 +76,16 @@ softpipe_flush( struct pipe_context *pipe,
        */
       softpipe_unmap_transfers(softpipe);
    }
+   else if (flags & PIPE_FLUSH_RENDER_CACHE) {
+      for (i = 0; i < softpipe->framebuffer.nr_cbufs; i++)
+         if (softpipe->cbuf_cache[i])
+            sp_flush_tile_cache(softpipe->cbuf_cache[i]);
+
+      if (softpipe->zsbuf_cache)
+         sp_flush_tile_cache(softpipe->zsbuf_cache);
+     
+      softpipe->dirty_render_cache = FALSE;
+   }
 
    /* Enable to dump BMPs of the color/depth buffers each frame */
 #if 0