gallium: add an index argument to create_query
authorIlia Mirkin <imirkin@alum.mit.edu>
Thu, 26 Jun 2014 23:33:07 +0000 (19:33 -0400)
committerIlia Mirkin <imirkin@alum.mit.edu>
Tue, 1 Jul 2014 15:34:31 +0000 (11:34 -0400)
Signed-off-by: Ilia Mirkin <imirkin@alum.mit.edu>
Reviewed-by: Marek Olšák <marek.olsak@amd.com>
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
25 files changed:
src/gallium/auxiliary/hud/hud_driver_query.c
src/gallium/docs/source/context.rst
src/gallium/drivers/freedreno/freedreno_query.c
src/gallium/drivers/galahad/glhd_context.c
src/gallium/drivers/i915/i915_query.c
src/gallium/drivers/identity/id_context.c
src/gallium/drivers/ilo/ilo_query.c
src/gallium/drivers/llvmpipe/lp_query.c
src/gallium/drivers/noop/noop_pipe.c
src/gallium/drivers/nouveau/nv30/nv30_query.c
src/gallium/drivers/nouveau/nv50/nv50_query.c
src/gallium/drivers/nouveau/nv50/nv50_state.c
src/gallium/drivers/nouveau/nvc0/nvc0_query.c
src/gallium/drivers/nouveau/nvc0/nvc0_state.c
src/gallium/drivers/r300/r300_query.c
src/gallium/drivers/radeon/r600_query.c
src/gallium/drivers/rbug/rbug_context.c
src/gallium/drivers/softpipe/sp_query.c
src/gallium/drivers/svga/svga_pipe_query.c
src/gallium/drivers/trace/tr_context.c
src/gallium/include/pipe/p_context.h
src/gallium/state_trackers/clover/core/timestamp.cpp
src/gallium/tests/graw/occlusion-query.c
src/gallium/tools/trace/dump_state.py
src/mesa/state_tracker/st_cb_queryobj.c

index 0f52e18cc2db258d69ff15c3334cc8b4e5485499..b48708c2fe6cfb3cbaa453a2c0084da9aec96247 100644 (file)
@@ -90,7 +90,7 @@ query_new_value(struct hud_graph *gr)
                        NUM_QUERIES);
                pipe->destroy_query(pipe, info->query[info->head]);
                info->query[info->head] =
-                     pipe->create_query(pipe, info->query_type);
+                     pipe->create_query(pipe, info->query_type, 0);
             }
             else {
                /* the last query is busy, we need to add a new one we can use
@@ -98,7 +98,7 @@ query_new_value(struct hud_graph *gr)
                info->head = (info->head+1) % NUM_QUERIES;
                if (!info->query[info->head]) {
                   info->query[info->head] =
-                        pipe->create_query(pipe, info->query_type);
+                        pipe->create_query(pipe, info->query_type, 0);
                }
             }
             break;
@@ -119,7 +119,7 @@ query_new_value(struct hud_graph *gr)
    else {
       /* initialize */
       info->last_time = now;
-      info->query[info->head] = pipe->create_query(pipe, info->query_type);
+      info->query[info->head] = pipe->create_query(pipe, info->query_type, 0);
       pipe->begin_query(pipe, info->query[info->head]);
    }
 }
index a9625f39edc1dab5d1a91f96bea769580df7ff61..5861f46b30dabe3b7aedb7d5514cc92c7bc972f4 100644 (file)
@@ -300,6 +300,10 @@ Queries can be created with ``create_query`` and deleted with
 ``destroy_query``. To start a query, use ``begin_query``, and when finished,
 use ``end_query`` to end the query.
 
+``create_query`` takes a query type (``PIPE_QUERY_*``), as well as an index,
+which is the vertex stream for ``PIPE_QUERY_PRIMITIVES_GENERATED`` and
+``PIPE_QUERY_PRIMITIVES_EMITTED``, and allocates a query structure.
+
 ``begin_query`` will clear/reset previous query results.
 
 ``get_query_result`` is used to retrieve the results of a query.  If
index 8753a4b02c98f3611bb018885e571a3ff019c829..cb3b49a5f5831ba6783277651cc77b7eacbe9302 100644 (file)
@@ -40,7 +40,7 @@
  */
 
 static struct pipe_query *
-fd_create_query(struct pipe_context *pctx, unsigned query_type)
+fd_create_query(struct pipe_context *pctx, unsigned query_type, unsigned index)
 {
        struct fd_context *ctx = fd_context(pctx);
        struct fd_query *q;
index 2e61e5924a67832d9d755d5aa83b228d5c58d51a..79d549585b7e3cfe95a0bf28d841dec13e640593 100644 (file)
@@ -63,7 +63,8 @@ galahad_context_draw_vbo(struct pipe_context *_pipe,
 
 static struct pipe_query *
 galahad_context_create_query(struct pipe_context *_pipe,
-                      unsigned query_type)
+                             unsigned query_type,
+                             unsigned index)
 {
    struct galahad_context *glhd_pipe = galahad_context(_pipe);
    struct pipe_context *pipe = glhd_pipe->pipe;
@@ -79,7 +80,8 @@ galahad_context_create_query(struct pipe_context *_pipe,
    }
 
    return pipe->create_query(pipe,
-                             query_type);
+                             query_type,
+                             index);
 }
 
 static void
index 0efceb192b63de350731bcf9e6464ec768f3a899..1500d970b0ff739dc48a8b1d8654ed4c1b486225 100644 (file)
@@ -40,7 +40,8 @@ struct i915_query
 };
 
 static struct pipe_query *i915_create_query(struct pipe_context *ctx,
-                                            unsigned query_type)
+                                            unsigned query_type,
+                                            unsigned index)
 {
    struct i915_query *query = CALLOC_STRUCT( i915_query );
 
index 00414b89624e61bafcd4ebf1f3b50d04381b4606..97b39671fce71a33cd6e620a031dcc55bc23cb50 100644 (file)
@@ -57,13 +57,15 @@ identity_draw_vbo(struct pipe_context *_pipe,
 
 static struct pipe_query *
 identity_create_query(struct pipe_context *_pipe,
-                      unsigned query_type)
+                      unsigned query_type,
+                      unsigned index)
 {
    struct identity_context *id_pipe = identity_context(_pipe);
    struct pipe_context *pipe = id_pipe->pipe;
 
    return pipe->create_query(pipe,
-                             query_type);
+                             query_type,
+                             index);
 }
 
 static void
index 71bcc0f983ff8169939aa17ac8a4af5ee88926a3..46e6bf766e16334ae6acb2984499dd87d6b6dfe2 100644 (file)
@@ -70,7 +70,7 @@ ilo_query(struct pipe_query *query)
 }
 
 static struct pipe_query *
-ilo_create_query(struct pipe_context *pipe, unsigned query_type)
+ilo_create_query(struct pipe_context *pipe, unsigned query_type, unsigned index)
 {
    struct ilo_query *q;
 
index 2bc9c1aeb867bfea0d23af118a4a560ff0243067..8f41f56f1c48118c74e4af43f0a2a90f61ebdef2 100644 (file)
@@ -50,7 +50,8 @@ static struct llvmpipe_query *llvmpipe_query( struct pipe_query *p )
 
 static struct pipe_query *
 llvmpipe_create_query(struct pipe_context *pipe, 
-                      unsigned type)
+                      unsigned type,
+                      unsigned index)
 {
    struct llvmpipe_query *pq;
 
index 27197a504545b706b088d95629a147b06c43f563..8cb8c702c0ea1924991d8cba892558a95a76e001 100644 (file)
@@ -46,7 +46,7 @@ struct noop_pipe_screen {
 struct noop_query {
        unsigned        query;
 };
-static struct pipe_query *noop_create_query(struct pipe_context *ctx, unsigned query_type)
+static struct pipe_query *noop_create_query(struct pipe_context *ctx, unsigned query_type, unsigned index)
 {
        struct noop_query *query = CALLOC_STRUCT(noop_query);
 
index 01b3817c45d4cdc7e948110b4919d5a033aa60d4..ace2cdcd79539a583700cc6c9c1df693f4cb8286 100644 (file)
@@ -105,7 +105,7 @@ nv30_query(struct pipe_query *pipe)
 }
 
 static struct pipe_query *
-nv30_query_create(struct pipe_context *pipe, unsigned type)
+nv30_query_create(struct pipe_context *pipe, unsigned type, unsigned index)
 {
    struct nv30_query *q = CALLOC_STRUCT(nv30_query);
    if (!q)
index 6a17139e1cde6e405f0fd19b24121a35b4133176..a373dc60a673802363a80a4f1b9c9c5a49314d88 100644 (file)
@@ -96,7 +96,7 @@ nv50_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
 }
 
 static struct pipe_query *
-nv50_query_create(struct pipe_context *pipe, unsigned type)
+nv50_query_create(struct pipe_context *pipe, unsigned type, unsigned index)
 {
    struct nv50_context *nv50 = nv50_context(pipe);
    struct nv50_query *q;
index d0bc7ff1a2a8b62209e9459f6f9c4f4b80685b87..915ee26ecacb9cde3337f7a89ff84e63815a0c0f 100644 (file)
@@ -1028,7 +1028,7 @@ nv50_so_target_create(struct pipe_context *pipe,
 
    if (nouveau_context(pipe)->screen->class_3d >= NVA0_3D_CLASS) {
       targ->pq = pipe->create_query(pipe,
-                                    NVA0_QUERY_STREAM_OUTPUT_BUFFER_OFFSET);
+                                    NVA0_QUERY_STREAM_OUTPUT_BUFFER_OFFSET, 0);
       if (!targ->pq) {
          FREE(targ);
          return NULL;
index 856f685ceb617808cd10d8bba506b598e90a8752..dc544d36efc6ff6d0f60128ec641c639e4154617 100644 (file)
@@ -108,7 +108,7 @@ nvc0_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
 }
 
 static struct pipe_query *
-nvc0_query_create(struct pipe_context *pipe, unsigned type)
+nvc0_query_create(struct pipe_context *pipe, unsigned type, unsigned index)
 {
    struct nvc0_context *nvc0 = nvc0_context(pipe);
    struct nvc0_query *q;
index c92aaaca5785667197ca2ee5b07dc5d0eadcc98b..ef9d479ca07975b6955b873c635f47f28d28076c 100644 (file)
@@ -1022,7 +1022,7 @@ nvc0_so_target_create(struct pipe_context *pipe,
    if (!targ)
       return NULL;
 
-   targ->pq = pipe->create_query(pipe, NVC0_QUERY_TFB_BUFFER_OFFSET);
+   targ->pq = pipe->create_query(pipe, NVC0_QUERY_TFB_BUFFER_OFFSET, 0);
    if (!targ->pq) {
       FREE(targ);
       return NULL;
index fbf44c68419d6ff958a623dc3034d81f16fa5ace..5305ebdcb7fd14f489524d5047ea771e9a3a9b08 100644 (file)
@@ -30,7 +30,8 @@
 #include <stdio.h>
 
 static struct pipe_query *r300_create_query(struct pipe_context *pipe,
-                                            unsigned query_type)
+                                            unsigned query_type,
+                                            unsigned index)
 {
     struct r300_context *r300 = r300_context(pipe);
     struct r300_screen *r300screen = r300->screen;
index c43944160039aa8a9cd55a97424adf56930abfe6..92863cb2143ffed57bac0c85d8307756ad5dbeb5 100644 (file)
@@ -346,7 +346,7 @@ static void r600_emit_query_predication(struct r600_common_context *ctx, struct
        }
 }
 
-static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned query_type)
+static struct pipe_query *r600_create_query(struct pipe_context *ctx, unsigned query_type, unsigned index)
 {
        struct r600_common_context *rctx = (struct r600_common_context *)ctx;
        struct r600_query *query;
index 2b99ddd72890631b5ef1ae022d9067ebfe933d73..62fe543b761c37f3eeab60a9a19c7af99ea1903d 100644 (file)
@@ -134,14 +134,16 @@ rbug_draw_vbo(struct pipe_context *_pipe, const struct pipe_draw_info *info)
 
 static struct pipe_query *
 rbug_create_query(struct pipe_context *_pipe,
-                  unsigned query_type)
+                  unsigned query_type,
+                  unsigned index)
 {
    struct rbug_context *rb_pipe = rbug_context(_pipe);
    struct pipe_context *pipe = rb_pipe->pipe;
 
    pipe_mutex_lock(rb_pipe->call_mutex);
    return pipe->create_query(pipe,
-                             query_type);
+                             query_type,
+                             index);
    pipe_mutex_unlock(rb_pipe->call_mutex);
 }
 
index 88223708f4f6f0de756db5adbcf974a5640483c1..e2fc917b3617509e924f73c77f2d24e49602bbdc 100644 (file)
@@ -53,7 +53,8 @@ static struct softpipe_query *softpipe_query( struct pipe_query *p )
 
 static struct pipe_query *
 softpipe_create_query(struct pipe_context *pipe, 
-                     unsigned type)
+                     unsigned type,
+                     unsigned index)
 {
    struct softpipe_query* sq;
 
index 0283aa907907d3aa6521be4a848ea84ad9611ce4..756e2b8baf4342f5499712d83448e4c321f9f8f6 100644 (file)
@@ -74,7 +74,9 @@ svga_get_query_result(struct pipe_context *pipe,
 
 
 static struct pipe_query *
-svga_create_query( struct pipe_context *pipe, unsigned query_type )
+svga_create_query(struct pipe_context *pipe,
+                  unsigned query_type,
+                  unsigned index)
 {
    struct svga_context *svga = svga_context( pipe );
    struct svga_screen *svgascreen = svga_screen(pipe->screen);
index 3e995980e921a8f2955b3d1f3a9ef96210ac7de8..551c3facb6492a42d2c65904af2761c2406cbc47 100644 (file)
@@ -127,7 +127,8 @@ trace_context_draw_vbo(struct pipe_context *_pipe,
 
 static INLINE struct pipe_query *
 trace_context_create_query(struct pipe_context *_pipe,
-                           unsigned query_type)
+                           unsigned query_type,
+                           unsigned index)
 {
    struct trace_context *tr_ctx = trace_context(_pipe);
    struct pipe_context *pipe = tr_ctx->pipe;
@@ -137,8 +138,9 @@ trace_context_create_query(struct pipe_context *_pipe,
 
    trace_dump_arg(ptr, pipe);
    trace_dump_arg(query_type, query_type);
+   trace_dump_arg(int, index);
 
-   query = pipe->create_query(pipe, query_type);
+   query = pipe->create_query(pipe, query_type, index);
 
    trace_dump_ret(ptr, query);
 
index bc435308d2eb05bdb50b279adcb13e25763e115e..af5674ff7535976e6bc78cb345ef2cd716daf04a 100644 (file)
@@ -109,7 +109,8 @@ struct pipe_context {
     */
    /*@{*/
    struct pipe_query *(*create_query)( struct pipe_context *pipe,
-                                       unsigned query_type );
+                                       unsigned query_type,
+                                       unsigned index );
 
    void (*destroy_query)(struct pipe_context *pipe,
                          struct pipe_query *q);
index f168d61b6c904f9f662b3925e10a572ff2e9a139..481c4f9d2ffb5520d32e0157832c5f9afdf1ca5d 100644 (file)
@@ -29,7 +29,7 @@ using namespace clover;
 
 timestamp::query::query(command_queue &q) :
    q(q),
-   _query(q.pipe->create_query(q.pipe, PIPE_QUERY_TIMESTAMP)) {
+   _query(q.pipe->create_query(q.pipe, PIPE_QUERY_TIMESTAMP, 0)) {
 }
 
 timestamp::query::query(query &&other) :
index f5227e33e9d55f0cde28b031b15a4de9a6f2aa23..d03934f9d19fc41d1cbcf063a2e92a517d61ab65 100644 (file)
@@ -169,8 +169,8 @@ draw(void)
                    PIPE_CLEAR_COLOR | PIPE_CLEAR_DEPTHSTENCIL,
                    &clear_color, 1.0, 0);
 
-   q1 = info.ctx->create_query(info.ctx, PIPE_QUERY_OCCLUSION_COUNTER);
-   q2 = info.ctx->create_query(info.ctx, PIPE_QUERY_OCCLUSION_COUNTER);
+   q1 = info.ctx->create_query(info.ctx, PIPE_QUERY_OCCLUSION_COUNTER, 0);
+   q2 = info.ctx->create_query(info.ctx, PIPE_QUERY_OCCLUSION_COUNTER, 0);
 
    /* draw first, large object */
    set_vertices(obj1_vertices, sizeof(obj1_vertices));
index 8bb29e7d6c1f030be78f90bdc90861e7d9a08c05..e726f7b2ad3fce10a5d65aa7a16c746a63d0526c 100755 (executable)
@@ -665,7 +665,7 @@ class Context(Dispatcher):
     def surface_destroy(self, surface):
         self.interpreter.unregister_object(surface)
 
-    def create_query(self, query_type):
+    def create_query(self, query_type, index):
         return query_type
     
     def destroy_query(self, query):
index 78a737094cd8d365d9ad797d8c9bee6e634fc280..1aaa322f6150b61427a7578e3ff8524b1032d3d6 100644 (file)
@@ -132,13 +132,13 @@ st_BeginQuery(struct gl_context *ctx, struct gl_query_object *q)
        type == PIPE_QUERY_TIMESTAMP) {
       /* Determine time elapsed by emitting two timestamp queries. */
       if (!stq->pq_begin) {
-         stq->pq_begin = pipe->create_query(pipe, type);
+         stq->pq_begin = pipe->create_query(pipe, type, 0);
          stq->type = type;
       }
       pipe->end_query(pipe, stq->pq_begin);
    } else {
       if (!stq->pq) {
-         stq->pq = pipe->create_query(pipe, type);
+         stq->pq = pipe->create_query(pipe, type, 0);
          stq->type = type;
       }
       if (stq->pq) {
@@ -164,7 +164,7 @@ st_EndQuery(struct gl_context *ctx, struct gl_query_object *q)
    if ((q->Target == GL_TIMESTAMP ||
         q->Target == GL_TIME_ELAPSED) &&
        !stq->pq) {
-      stq->pq = pipe->create_query(pipe, PIPE_QUERY_TIMESTAMP);
+      stq->pq = pipe->create_query(pipe, PIPE_QUERY_TIMESTAMP, 0);
       stq->type = PIPE_QUERY_TIMESTAMP;
    }