i915g: Change state code in vbuf code
[mesa.git] / src / gallium / drivers / r300 / r300_flush.c
index 70de152713d8b267bdfa606d47ff4da89a5fb3e3..ba840bfff81b8b68da3f4aa3d22a7dfb9d70bb6e 100644 (file)
@@ -1,5 +1,6 @@
 /*
  * Copyright 2008 Corbin Simpson <MostAwesomeDude@gmail.com>
+ * Copyright 2010 Marek Olšák <maraeo@gmail.com>
  *
  * Permission is hereby granted, free of charge, to any person obtaining a
  * copy of this software and associated documentation files (the "Software"),
@@ -28,7 +29,6 @@
 #include "r300_context.h"
 #include "r300_cs.h"
 #include "r300_emit.h"
-#include "r300_flush.h"
 
 static void r300_flush(struct pipe_context* pipe,
                        unsigned flags,
@@ -37,9 +37,8 @@ static void r300_flush(struct pipe_context* pipe,
     struct r300_context *r300 = r300_context(pipe);
     struct r300_query *query;
     struct r300_atom *atom;
+    struct r300_fence **rfence = (struct r300_fence**)fence;
 
-    CS_LOCALS(r300);
-    (void) cs_count;
     /* We probably need to flush Draw, but we may have been called from
      * within Draw. This feels kludgy, but it might be the best thing.
      *
@@ -48,24 +47,26 @@ static void r300_flush(struct pipe_context* pipe,
         draw_flush(r300->draw);
     }
 
-    r300_emit_query_end(r300);
-
     if (r300->dirty_hw) {
-        FLUSH_CS;
-        r300->dirty_state = R300_NEW_KITCHEN_SINK;
+        r300_emit_query_end(r300);
+
+        if (SCREEN_DBG_ON(r300->screen, DBG_STATS)) {
+            r300->flush_counter++;
+        }
+        r300->rws->flush_cs(r300->rws);
         r300->dirty_hw = 0;
 
         /* New kitchen sink, baby. */
         foreach(atom, &r300->atom_list) {
-            if (atom->state) {
+            if (atom->state || atom->allow_null_state) {
                 atom->dirty = TRUE;
             }
         }
 
         /* Unmark HWTCL state for SWTCL. */
-        if (!r300_screen(pipe->screen)->caps->has_tcl) {
+        if (!r300->screen->caps.has_tcl) {
             r300->vs_state.dirty = FALSE;
-            r300->dirty_state &= ~R300_NEW_VERTEX_SHADER_CONSTANTS;
+            r300->vs_constants.dirty = FALSE;
         }
     }
 
@@ -73,8 +74,14 @@ static void r300_flush(struct pipe_context* pipe,
     foreach(query, &r300->query_list) {
         query->flushed = TRUE;
     }
-}
 
+    /* Create a new fence. */
+    if (rfence) {
+        *rfence = CALLOC_STRUCT(r300_fence);
+        pipe_reference_init(&(*rfence)->reference, 1);
+        (*rfence)->ctx = r300;
+    }
+}
 
 void r300_init_flush_functions(struct r300_context* r300)
 {