r300g: more efficient finish + fix comments
[mesa.git] / src / gallium / drivers / r300 / r300_query.c
index 3348a0ada61c3aa88ab0068c31b59b412931b8d5..4ce7114d821ab8318ace6c59450b83c7e8ec0223 100644 (file)
 
 #include "r300_context.h"
 #include "r300_screen.h"
-#include "r300_cs.h"
 #include "r300_emit.h"
-#include "r300_query.h"
-#include "r300_reg.h"
 
 #include <stdio.h>
 
@@ -45,8 +42,6 @@ static struct pipe_query *r300_create_query(struct pipe_context *pipe,
     q->type = query_type;
     assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
 
-    q->active = FALSE;
-
     if (r300screen->caps.family == CHIP_FAMILY_RV530)
         query_size = r300screen->caps.num_z_pipes * sizeof(uint32_t);
     else
@@ -61,6 +56,7 @@ static struct pipe_query *r300_create_query(struct pipe_context *pipe,
     /* XXX */
     if (q->offset >= 4096) {
         q->offset = 0;
+        fprintf(stderr, "r300: Rewinding OQBO...\n");
     }
 
     return (struct pipe_query*)q;
@@ -82,7 +78,12 @@ static void r300_begin_query(struct pipe_context* pipe,
     struct r300_context* r300 = r300_context(pipe);
     struct r300_query* q = (struct r300_query*)query;
 
-    assert(r300->query_current == NULL);
+    if (r300->query_current != NULL) {
+        fprintf(stderr, "r300: begin_query: "
+                "Some other query has already been started.\n");
+        assert(0);
+        return;
+    }
 
     pipe_buffer_write(pipe,
                      r300->oqbo,
@@ -92,17 +93,21 @@ static void r300_begin_query(struct pipe_context* pipe,
 
     q->flushed = FALSE;
     r300->query_current = q;
-    r300->dirty_state |= R300_NEW_QUERY;
+    r300->query_start.dirty = TRUE;
 }
 
 static void r300_end_query(struct pipe_context* pipe,
                           struct pipe_query* query)
 {
     struct r300_context* r300 = r300_context(pipe);
-    struct r300_query* q = (struct r300_query*)query;
+
+    if ((struct r300_query*)query != r300->query_current) {
+        fprintf(stderr, "r300: end_query: Got invalid query.\n");
+        assert(0);
+        return;
+    }
 
     r300_emit_query_end(r300);
-    q->begin_emitted = false;
     r300->query_current = NULL;
 }