Merge remote branch 'origin/gallium-0.2' into gallium-0.2
[mesa.git] / src / gallium / drivers / nv40 / nv40_query.c
index 03178456246cefb263cea0a055b7289e7b563a02..57f39cfab0cbfe8e343b876beb9a90a95bf16c62 100644 (file)
@@ -34,7 +34,7 @@ nv40_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
 
        if (q->object)
                nv40->nvws->res_free(&q->object);
-       free(q);
+       FREE(q);
 }
 
 static void
@@ -45,6 +45,15 @@ nv40_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
 
        assert(q->type == PIPE_QUERY_OCCLUSION_COUNTER);
 
+       /* Happens when end_query() is called, then another begin_query()
+        * without querying the result in-between.  For now we'll wait for
+        * the existing query to notify completion, but it could be better.
+        */
+       if (q->object) {
+               uint64 tmp;
+               pipe->get_query_result(pipe, pq, 1, &tmp);
+       }
+
        if (nv40->nvws->res_alloc(nv40->screen->query_heap, 1, NULL, &q->object))
                assert(0);
        nv40->nvws->notifier_reset(nv40->screen->query, q->object->start);
@@ -66,7 +75,7 @@ nv40_query_end(struct pipe_context *pipe, struct pipe_query *pq)
        BEGIN_RING(curie, NV40TCL_QUERY_GET, 1);
        OUT_RING  ((0x01 << NV40TCL_QUERY_GET_UNK24_SHIFT) |
                   ((q->object->start * 32) << NV40TCL_QUERY_GET_OFFSET_SHIFT));
-       FIRE_RING();
+       FIRE_RING(NULL);
 }
 
 static boolean