r300g: fix glean/pointSprite using lodbias correction
[mesa.git] / src / gallium / drivers / r300 / r300_query.c
index bc40fcfb5ba3cf6e408ee98ed82eb04354063a82..5c27796e894d3b93bac0c1c9621ee7983d6b7c6b 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>
 
@@ -78,21 +76,21 @@ static void r300_destroy_query(struct pipe_context* pipe,
 static void r300_begin_query(struct pipe_context* pipe,
                              struct pipe_query* query)
 {
-    uint32_t* map;
+    uint32_t value = ~0U;
     struct r300_context* r300 = r300_context(pipe);
     struct r300_query* q = (struct r300_query*)query;
 
     assert(r300->query_current == NULL);
 
-    map = pipe->screen->buffer_map(pipe->screen, r300->oqbo,
-            PIPE_BUFFER_USAGE_CPU_WRITE);
-    map += q->offset / 4;
-    *map = ~0U;
-    pipe->screen->buffer_unmap(pipe->screen, r300->oqbo);
+    pipe_buffer_write(pipe,
+                     r300->oqbo,
+                     q->offset,
+                     sizeof value,
+                     &value);
 
     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,
@@ -114,7 +112,8 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
     struct r300_context* r300 = r300_context(pipe);
     struct r300_screen* r300screen = r300->screen;
     struct r300_query *q = (struct r300_query*)query;
-    unsigned flags = PIPE_BUFFER_USAGE_CPU_READ;
+    struct pipe_transfer *transfer;
+    unsigned flags = PIPE_TRANSFER_READ;
     uint32_t* map;
     uint32_t temp = 0;
     unsigned i, num_results;
@@ -122,10 +121,10 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
     if (q->flushed == FALSE)
         pipe->flush(pipe, 0, NULL);
     if (!wait) {
-        flags |= PIPE_BUFFER_USAGE_DONTBLOCK;
+        flags |= PIPE_TRANSFER_DONTBLOCK;
     }
 
-    map = pipe->screen->buffer_map(pipe->screen, r300->oqbo, flags);
+    map = pipe_buffer_map(pipe, r300->oqbo, flags, &transfer);
     if (!map)
         return FALSE;
     map += q->offset / 4;
@@ -148,7 +147,7 @@ static boolean r300_get_query_result(struct pipe_context* pipe,
         temp += *map;
         map++;
     }
-    pipe->screen->buffer_unmap(pipe->screen, r300->oqbo);
+    pipe_buffer_unmap(pipe, r300->oqbo, transfer);
 
     if (temp == ~0U) {
         /* Our results haven't been written yet... */