nouveau: Add support for XvMC acceleration
[mesa.git] / src / gallium / drivers / nvfx / nvfx_query.c
index 1dab20c41a02ae4019123c117aa06a27cdd01211..3cd6bf1e477d6870a96afecdf5ed90779549322f 100644 (file)
@@ -52,6 +52,8 @@ nvfx_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
        struct nouveau_grobj *eng3d = screen->eng3d;
        uint64_t tmp;
 
+       assert(!nvfx->query);
+
        /* 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.
@@ -71,27 +73,34 @@ nvfx_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
 
        nouveau_notifier_reset(nvfx->screen->query, q->object->start);
 
-       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_RESET, 1);
-       OUT_RING  (chan, 1);
-       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_UNK17CC, 1);
-       OUT_RING  (chan, 1);
+       BEGIN_RING(chan, eng3d, NV30_3D_QUERY_RESET, 1);
+       OUT_RING(chan, 1);
+       BEGIN_RING(chan, eng3d, NV30_3D_QUERY_ENABLE, 1);
+       OUT_RING(chan, 1);
 
        q->ready = FALSE;
+
+       nvfx->query = pq;
 }
 
 static void
 nvfx_query_end(struct pipe_context *pipe, struct pipe_query *pq)
 {
        struct nvfx_context *nvfx = nvfx_context(pipe);
-       struct nvfx_screen *screen = nvfx->screen;
-       struct nouveau_channel *chan = screen->base.channel;
-       struct nouveau_grobj *eng3d = screen->eng3d;
+       struct nouveau_channel *chan = nvfx->screen->base.channel;
+       struct nouveau_grobj *eng3d = nvfx->screen->eng3d;
        struct nvfx_query *q = nvfx_query(pq);
 
-       BEGIN_RING(chan, eng3d, NV34TCL_QUERY_GET, 1);
-       OUT_RING  (chan, (0x01 << NV34TCL_QUERY_GET_UNK24_SHIFT) |
-                  ((q->object->start * 32) << NV34TCL_QUERY_GET_OFFSET_SHIFT));
+       assert(nvfx->query == pq);
+
+       BEGIN_RING(chan, eng3d, NV30_3D_QUERY_GET, 1);
+       OUT_RING  (chan, (0x01 << NV30_3D_QUERY_GET_UNK24__SHIFT) |
+                  ((q->object->start * 32) << NV30_3D_QUERY_GET_OFFSET__SHIFT));
+       BEGIN_RING(chan, eng3d, NV30_3D_QUERY_ENABLE, 1);
+       OUT_RING(chan, 0);
        FIRE_RING(chan);
+
+       nvfx->query = 0;
 }
 
 static boolean