gallium: Move minify() to u_math.
[mesa.git] / src / gallium / drivers / softpipe / sp_context.c
index 11aff814791e7280c0c3b299378ed5d447fe4f02..86df320ea8ab93580705ccd51b616cf9776ac2ee 100644 (file)
@@ -126,14 +126,30 @@ softpipe_is_texture_referenced( struct pipe_context *pipe,
                                struct pipe_texture *texture,
                                unsigned face, unsigned level)
 {
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+   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;
 }
 
 static unsigned int
 softpipe_is_buffer_referenced( struct pipe_context *pipe,
                               struct pipe_buffer *buf)
 {
-   return PIPE_REFERENCED_FOR_READ | PIPE_REFERENCED_FOR_WRITE;
+   return PIPE_UNREFERENCED;
 }
 
 struct pipe_context *