Merge branch 'mesa_7_7_branch'
[mesa.git] / src / gallium / drivers / failover / fo_context.c
index 10c4ffc2096cba653868ef9ca5af238efa4fd97b..46e4338d98ae05a8d211e0654de8df245d09870f 100644 (file)
@@ -27,7 +27,7 @@
 
 
 #include "pipe/p_defines.h"
-#include "pipe/p_winsys.h"
+#include "pipe/internal/p_winsys_screen.h"
 #include "util/u_memory.h"
 #include "pipe/p_context.h"
 
@@ -44,11 +44,19 @@ static void failover_destroy( struct pipe_context *pipe )
 }
 
 
+void failover_fail_over( struct failover_context *failover )
+{
+   failover->dirty = TRUE;
+   failover->mode = FO_SW;
+}
+
 
-static boolean failover_draw_elements( struct pipe_context *pipe,
-                                      struct pipe_buffer *indexBuffer,
-                                      unsigned indexSize,
-                                      unsigned prim, unsigned start, unsigned count)
+static void failover_draw_elements( struct pipe_context *pipe,
+                                    struct pipe_buffer *indexBuffer,
+                                    unsigned indexSize,
+                                    unsigned prim, 
+                                    unsigned start, 
+                                    unsigned count)
 {
    struct failover_context *failover = failover_context( pipe );
 
@@ -62,24 +70,22 @@ static boolean failover_draw_elements( struct pipe_context *pipe,
    /* Try hardware:
     */
    if (failover->mode == FO_HW) {
-      if (!failover->hw->draw_elements( failover->hw, 
-                                       indexBuffer, 
-                                       indexSize, 
-                                       prim, 
-                                       start, 
-                                       count )) {
-
-        failover->hw->flush( failover->hw, ~0, NULL );
-        failover->mode = FO_SW;
-      }
+      failover->hw->draw_elements( failover->hw, 
+                                   indexBuffer, 
+                                   indexSize, 
+                                   prim, 
+                                   start, 
+                                   count );
    }
 
    /* Possibly try software:
     */
    if (failover->mode == FO_SW) {
 
-      if (failover->dirty) 
+      if (failover->dirty) {
+         failover->hw->flush( failover->hw, ~0, NULL );
         failover_state_emit( failover );
+      }
 
       failover->sw->draw_elements( failover->sw, 
                                   indexBuffer, 
@@ -94,18 +100,37 @@ static boolean failover_draw_elements( struct pipe_context *pipe,
        */
       failover->sw->flush( failover->sw, ~0, NULL );
    }
-
-   return TRUE;
 }
 
 
-static boolean failover_draw_arrays( struct pipe_context *pipe,
+static void failover_draw_arrays( struct pipe_context *pipe,
                                     unsigned prim, unsigned start, unsigned count)
 {
-   return failover_draw_elements(pipe, NULL, 0, prim, start, count);
+   failover_draw_elements(pipe, NULL, 0, prim, start, count);
 }
 
+static unsigned int
+failover_is_texture_referenced( struct pipe_context *_pipe,
+                               struct pipe_texture *texture,
+                               unsigned face, unsigned level)
+{
+   struct failover_context *failover = failover_context( _pipe );
+   struct pipe_context *pipe = (failover->mode == FO_HW) ?
+      failover->hw : failover->sw;
+
+   return pipe->is_texture_referenced(pipe, texture, face, level);
+}
 
+static unsigned int
+failover_is_buffer_referenced( struct pipe_context *_pipe,
+                              struct pipe_buffer *buf)
+{
+   struct failover_context *failover = failover_context( _pipe );
+   struct pipe_context *pipe = (failover->mode == FO_HW) ?
+      failover->hw : failover->sw;
+
+   return pipe->is_buffer_referenced(pipe, buf);
+}
 
 struct pipe_context *failover_create( struct pipe_context *hw,
                                      struct pipe_context *sw )
@@ -145,12 +170,14 @@ struct pipe_context *failover_create( struct pipe_context *hw,
 
 #if 0
    failover->pipe.texture_create = hw->texture_create;
-   failover->pipe.texture_release = hw->texture_release;
+   failover->pipe.texture_destroy = hw->texture_destroy;
    failover->pipe.get_tex_surface = hw->get_tex_surface;
    failover->pipe.texture_update = hw->texture_update;
 #endif
 
    failover->pipe.flush = hw->flush;
+   failover->pipe.is_texture_referenced = failover_is_texture_referenced;
+   failover->pipe.is_buffer_referenced = failover_is_buffer_referenced;
 
    failover->dirty = 0;