gallium: add pipe_context::set_active_query_state for pausing queries
authorMarek Olšák <marek.olsak@amd.com>
Thu, 7 Apr 2016 23:42:00 +0000 (01:42 +0200)
committerMarek Olšák <marek.olsak@amd.com>
Tue, 12 Apr 2016 12:29:46 +0000 (14:29 +0200)
Reviewed-by: Roland Scheidegger <sroland@vmware.com>
Reviewed-by: Nicolai Hähnle <nicolai.haehnle@amd.com>
20 files changed:
src/gallium/docs/source/context.rst
src/gallium/drivers/ddebug/dd_context.c
src/gallium/drivers/freedreno/freedreno_query.c
src/gallium/drivers/i915/i915_query.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/nvc0/nvc0_query.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/swr/swr_query.cpp
src/gallium/drivers/trace/tr_context.c
src/gallium/drivers/vc4/vc4_query.c
src/gallium/drivers/virgl/virgl_query.c
src/gallium/include/pipe/p_context.h

index 904e1ff04e78a551ab89f9927ad989a6b618d0b5..3a45f402cd841f97fb98ba824d5f19711aa0f9f8 100644 (file)
@@ -330,6 +330,9 @@ a resource without synchronizing with the CPU. This write will optionally
 wait for the query to complete, and will optionally write whether the value
 is available instead of the value itself.
 
+``set_active_query_state`` Set whether all current non-driver queries except
+TIME_ELAPSED are active or paused.
+
 The interface currently includes the following types of queries:
 
 ``PIPE_QUERY_OCCLUSION_COUNTER`` counts the number of fragments which
index 9dfaa0af2898419affe5386b9d3cb5770986152a..72a950a456ad0a383ef88e79c18c5d887322e78e 100644 (file)
@@ -123,6 +123,14 @@ dd_context_get_query_result(struct pipe_context *_pipe,
    return pipe->get_query_result(pipe, dd_query_unwrap(query), wait, result);
 }
 
+static void
+dd_context_set_active_query_state(struct pipe_context *_pipe, boolean enable)
+{
+   struct pipe_context *pipe = dd_context(_pipe)->pipe;
+
+   pipe->set_active_query_state(pipe, enable);
+}
+
 static void
 dd_context_render_condition(struct pipe_context *_pipe,
                             struct pipe_query *query, boolean condition,
@@ -667,6 +675,7 @@ dd_context_create(struct dd_screen *dscreen, struct pipe_context *pipe)
    CTX_INIT(begin_query);
    CTX_INIT(end_query);
    CTX_INIT(get_query_result);
+   CTX_INIT(set_active_query_state);
    CTX_INIT(create_blend_state);
    CTX_INIT(bind_blend_state);
    CTX_INIT(delete_blend_state);
index b87e825071941df80dd7e981f7bb85c2bb0a961f..a9427058579dc1af711e28e03c90e7ba975853aa 100644 (file)
@@ -114,6 +114,11 @@ fd_get_driver_query_info(struct pipe_screen *pscreen,
        return 1;
 }
 
+static void
+fd_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void
 fd_query_screen_init(struct pipe_screen *pscreen)
 {
@@ -128,5 +133,6 @@ fd_query_context_init(struct pipe_context *pctx)
        pctx->begin_query = fd_begin_query;
        pctx->end_query = fd_end_query;
        pctx->get_query_result = fd_get_query_result;
+       pctx->set_active_query_state = fd_set_active_query_state;
        pctx->render_condition = fd_render_condition;
 }
index 78d67cea2c94f79af952231fd9271fab9797fb36..fa1b01d180427385d36d1ba328e9a52172024e1a 100644 (file)
@@ -76,6 +76,11 @@ static boolean i915_get_query_result(struct pipe_context *ctx,
    return TRUE;
 }
 
+static void
+i915_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void
 i915_init_query_functions(struct i915_context *i915)
 {
@@ -84,5 +89,6 @@ i915_init_query_functions(struct i915_context *i915)
    i915->base.begin_query = i915_begin_query;
    i915->base.end_query = i915_end_query;
    i915->base.get_query_result = i915_get_query_result;
+   i915->base.set_active_query_state = i915_set_active_query_state;
 }
 
index 106bd42a335061a455bdf642ac4e10992f71ea69..8a42f58a87f5560e963c396bb375639f3264c7cc 100644 (file)
@@ -222,6 +222,11 @@ ilo_get_query_result(struct pipe_context *pipe, struct pipe_query *query,
    return true;
 }
 
+static void
+ilo_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 /**
  * Initialize query-related functions.
  */
@@ -233,4 +238,5 @@ ilo_init_query_functions(struct ilo_context *ilo)
    ilo->base.begin_query = ilo_begin_query;
    ilo->base.end_query = ilo_end_query;
    ilo->base.get_query_result = ilo_get_query_result;
+   ilo->base.set_active_query_state = ilo_set_active_query_state;
 }
index fc5936706712f745f3ca25c3f193f6e878557822..2fddc90503f2c19f79ffd17b0e9bc2c3737f0643 100644 (file)
@@ -320,6 +320,11 @@ llvmpipe_check_render_cond(struct llvmpipe_context *lp)
       return TRUE;
 }
 
+static void
+llvmpipe_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void llvmpipe_init_query_funcs(struct llvmpipe_context *llvmpipe )
 {
    llvmpipe->pipe.create_query = llvmpipe_create_query;
@@ -327,6 +332,7 @@ void llvmpipe_init_query_funcs(struct llvmpipe_context *llvmpipe )
    llvmpipe->pipe.begin_query = llvmpipe_begin_query;
    llvmpipe->pipe.end_query = llvmpipe_end_query;
    llvmpipe->pipe.get_query_result = llvmpipe_get_query_result;
+   llvmpipe->pipe.set_active_query_state = llvmpipe_set_active_query_state;
 }
 
 
index fd0a5d0f830e85f7622d2636f1a3c7224ec93923..55aca74628e41838570e413768f36d2dbf1df97c 100644 (file)
@@ -78,6 +78,11 @@ static boolean noop_get_query_result(struct pipe_context *ctx,
        return TRUE;
 }
 
+static void
+noop_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 
 /*
  * resource
@@ -284,6 +289,7 @@ static struct pipe_context *noop_create_context(struct pipe_screen *screen,
        ctx->begin_query = noop_begin_query;
        ctx->end_query = noop_end_query;
        ctx->get_query_result = noop_get_query_result;
+       ctx->set_active_query_state = noop_set_active_query_state;
        ctx->transfer_map = noop_transfer_map;
        ctx->transfer_flush_region = noop_transfer_flush_region;
        ctx->transfer_unmap = noop_transfer_unmap;
index 75a4b0446fee9ce5e7808c59da9ef50ec0c008ad..cb53a3663e52d8379306e0ad54a8bc98566782f7 100644 (file)
@@ -263,6 +263,11 @@ nv40_query_render_condition(struct pipe_context *pipe,
    PUSH_DATA (push, 0x02000000 | q->qo[1]->hw->start);
 }
 
+static void
+nv30_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void
 nv30_query_init(struct pipe_context *pipe)
 {
@@ -273,6 +278,7 @@ nv30_query_init(struct pipe_context *pipe)
    pipe->begin_query = nv30_query_begin;
    pipe->end_query = nv30_query_end;
    pipe->get_query_result = nv30_query_result;
+   pipe->set_active_query_state = nv30_set_active_query_state;
    if (eng3d->oclass >= NV40_3D_CLASS)
       pipe->render_condition = nv40_query_render_condition;
 }
index 4cd3b6156067703a212a8e83161cf7f93184eb01..fa70fb6950e0ea98252d8d0a798b5a9bd2bcc628 100644 (file)
@@ -143,6 +143,11 @@ nv50_render_condition(struct pipe_context *pipe,
    PUSH_DATA (push, hq->bo->offset + hq->offset);
 }
 
+static void
+nv50_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void
 nv50_init_query_functions(struct nv50_context *nv50)
 {
@@ -153,6 +158,7 @@ nv50_init_query_functions(struct nv50_context *nv50)
    pipe->begin_query = nv50_begin_query;
    pipe->end_query = nv50_end_query;
    pipe->get_query_result = nv50_get_query_result;
+   pipe->set_active_query_state = nv50_set_active_query_state;
    pipe->render_condition = nv50_render_condition;
    nv50->cond_condmode = NV50_3D_COND_MODE_ALWAYS;
 }
index 92ca613cda1efb40151d97d5dd6537bb387bf04c..b34271c49117324696994ddcb63e74c7ebe74145 100644 (file)
@@ -254,6 +254,11 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen *pscreen,
    return 0;
 }
 
+static void
+nvc0_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void
 nvc0_init_query_functions(struct nvc0_context *nvc0)
 {
@@ -265,6 +270,7 @@ nvc0_init_query_functions(struct nvc0_context *nvc0)
    pipe->end_query = nvc0_end_query;
    pipe->get_query_result = nvc0_get_query_result;
    pipe->get_query_result_resource = nvc0_get_query_result_resource;
+   pipe->set_active_query_state = nvc0_set_active_query_state;
    pipe->render_condition = nvc0_render_condition;
    nvc0->cond_condmode = NVC0_3D_COND_MODE_ALWAYS;
 }
index 6414e80828e3dc99e194086755c1d3d80e02a2c0..7603985b14b6836c40b996d52e77f4ab9dd9a042 100644 (file)
@@ -200,6 +200,11 @@ static void r300_render_condition(struct pipe_context *pipe,
     }
 }
 
+static void
+r300_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void r300_init_query_functions(struct r300_context* r300)
 {
     r300->context.create_query = r300_create_query;
@@ -207,5 +212,6 @@ void r300_init_query_functions(struct r300_context* r300)
     r300->context.begin_query = r300_begin_query;
     r300->context.end_query = r300_end_query;
     r300->context.get_query_result = r300_get_query_result;
+    r300->context.set_active_query_state = r300_set_active_query_state;
     r300->context.render_condition = r300_render_condition;
 }
index 7a2d2ee7f316d7e6b9a7e1ea08305fdec882f9fc..d780b8c182f22ffbb40bc8eedba75c26bde1e31c 100644 (file)
@@ -1261,6 +1261,11 @@ static int r600_get_driver_query_group_info(struct pipe_screen *screen,
        return 1;
 }
 
+static void
+r600_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void r600_query_init(struct r600_common_context *rctx)
 {
        rctx->b.create_query = r600_create_query;
@@ -1269,6 +1274,7 @@ void r600_query_init(struct r600_common_context *rctx)
        rctx->b.begin_query = r600_begin_query;
        rctx->b.end_query = r600_end_query;
        rctx->b.get_query_result = r600_get_query_result;
+       rctx->b.set_active_query_state = r600_set_active_query_state;
        rctx->render_cond_atom.emit = r600_emit_query_predication;
 
        if (((struct r600_common_screen*)rctx->b.screen)->info.num_render_backends > 0)
index 9ecddad05ec762ae722775911a9f595da624adac..1280c45b53922b67ab792515de9d6888d4a72f1e 100644 (file)
@@ -211,6 +211,17 @@ rbug_get_query_result(struct pipe_context *_pipe,
    return ret;
 }
 
+static void
+rbug_set_active_query_state(struct pipe_context *_pipe, boolean enable)
+{
+   struct rbug_context *rb_pipe = rbug_context(_pipe);
+   struct pipe_context *pipe = rb_pipe->pipe;
+
+   pipe_mutex_lock(rb_pipe->call_mutex);
+   pipe->set_active_query_state(pipe, enable);
+   pipe_mutex_unlock(rb_pipe->call_mutex);
+}
+
 static void *
 rbug_create_blend_state(struct pipe_context *_pipe,
                         const struct pipe_blend_state *blend)
@@ -1184,6 +1195,7 @@ rbug_context_create(struct pipe_screen *_screen, struct pipe_context *pipe)
    rb_pipe->base.begin_query = rbug_begin_query;
    rb_pipe->base.end_query = rbug_end_query;
    rb_pipe->base.get_query_result = rbug_get_query_result;
+   rb_pipe->base.set_active_query_state = rbug_set_active_query_state;
    rb_pipe->base.create_blend_state = rbug_create_blend_state;
    rb_pipe->base.bind_blend_state = rbug_bind_blend_state;
    rb_pipe->base.delete_blend_state = rbug_delete_blend_state;
index c28d28d5f5d75d9ffc2a34bfd3cb0751e5c42a72..81e97107d59ece36dc36acbb20ba46f261aba6e0 100644 (file)
@@ -283,6 +283,12 @@ softpipe_check_render_cond(struct softpipe_context *sp)
 }
 
 
+static void
+softpipe_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
+
 void softpipe_init_query_funcs(struct softpipe_context *softpipe )
 {
    softpipe->pipe.create_query = softpipe_create_query;
@@ -290,6 +296,7 @@ void softpipe_init_query_funcs(struct softpipe_context *softpipe )
    softpipe->pipe.begin_query = softpipe_begin_query;
    softpipe->pipe.end_query = softpipe_end_query;
    softpipe->pipe.get_query_result = softpipe_get_query_result;
+   softpipe->pipe.set_active_query_state = softpipe_set_active_query_state;
 }
 
 
index 88f41eadc1d272c00e145920382398d21345cc04..75bc9ce092bb42abf4aac228aa0abc81dfb5bee9 100644 (file)
@@ -1246,6 +1246,12 @@ svga_get_timestamp(struct pipe_context *pipe)
 }
 
 
+static void
+svga_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
+
 void
 svga_init_query_functions(struct svga_context *svga)
 {
@@ -1254,6 +1260,7 @@ svga_init_query_functions(struct svga_context *svga)
    svga->pipe.begin_query = svga_begin_query;
    svga->pipe.end_query = svga_end_query;
    svga->pipe.get_query_result = svga_get_query_result;
+   svga->pipe.set_active_query_state = svga_set_active_query_state;
    svga->pipe.render_condition = svga_render_condition;
    svga->pipe.get_timestamp = svga_get_timestamp;
 }
index 810c50b2f8fbbe305c7e0ea478c6dec56ff4faf3..e4b8b683278d03f2b772264bf205955df4a00eb6 100644 (file)
@@ -319,6 +319,12 @@ swr_check_render_cond(struct pipe_context *pipe)
       return TRUE;
 }
 
+
+static void
+swr_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void
 swr_query_init(struct pipe_context *pipe)
 {
@@ -329,6 +335,7 @@ swr_query_init(struct pipe_context *pipe)
    pipe->begin_query = swr_begin_query;
    pipe->end_query = swr_end_query;
    pipe->get_query_result = swr_get_query_result;
+   pipe->set_active_query_state = swr_set_active_query_state;
 
    ctx->active_queries = 0;
 }
index 08b1d32afb044d92a179bf55f13f54ec0c40bd7a..b575f2cdb347b1eaed3935b77bf2c44a1180cda2 100644 (file)
@@ -273,6 +273,24 @@ trace_context_get_query_result(struct pipe_context *_pipe,
 }
 
 
+static void
+trace_context_set_active_query_state(struct pipe_context *_pipe,
+                                     boolean enable)
+{
+   struct trace_context *tr_ctx = trace_context(_pipe);
+   struct pipe_context *pipe = tr_ctx->pipe;
+
+   trace_dump_call_begin("pipe_context", "set_active_query_state");
+
+   trace_dump_arg(ptr, pipe);
+   trace_dump_arg(bool, enable);
+
+   pipe->set_active_query_state(pipe, enable);
+
+   trace_dump_call_end();
+}
+
+
 static void *
 trace_context_create_blend_state(struct pipe_context *_pipe,
                                  const struct pipe_blend_state *state)
@@ -1781,6 +1799,7 @@ trace_context_create(struct trace_screen *tr_scr,
    TR_CTX_INIT(begin_query);
    TR_CTX_INIT(end_query);
    TR_CTX_INIT(get_query_result);
+   TR_CTX_INIT(set_active_query_state);
    TR_CTX_INIT(create_blend_state);
    TR_CTX_INIT(bind_blend_state);
    TR_CTX_INIT(delete_blend_state);
index 270832eae3aa6ed86567615b38fb0aa3cf8abbc9..17400a37ca3884d3816c6f521ca8dafcf70b3ffc 100644 (file)
@@ -72,6 +72,11 @@ vc4_get_query_result(struct pipe_context *ctx, struct pipe_query *query,
         return true;
 }
 
+static void
+vc4_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void
 vc4_query_init(struct pipe_context *pctx)
 {
@@ -80,5 +85,6 @@ vc4_query_init(struct pipe_context *pctx)
         pctx->begin_query = vc4_begin_query;
         pctx->end_query = vc4_end_query;
         pctx->get_query_result = vc4_get_query_result;
+       pctx->set_active_query_state = vc4_set_active_query_state;
 }
 
index b020055634201eb79a62e31ac9d4a0a66c5f8595..5173bd39a45f2e7c7add58e22e1e98c0f896292f 100644 (file)
@@ -164,6 +164,11 @@ static boolean virgl_get_query_result(struct pipe_context *ctx,
    return TRUE;
 }
 
+static void
+virgl_set_active_query_state(struct pipe_context *pipe, boolean enable)
+{
+}
+
 void virgl_init_query_functions(struct virgl_context *vctx)
 {
    vctx->base.render_condition = virgl_render_condition;
@@ -172,4 +177,5 @@ void virgl_init_query_functions(struct virgl_context *vctx)
    vctx->base.begin_query = virgl_begin_query;
    vctx->base.end_query = virgl_end_query;
    vctx->base.get_query_result = virgl_get_query_result;
+   vctx->base.set_active_query_state = virgl_set_active_query_state;
 }
index 1c97e82ece54890abdc513a844b009c8f60c939f..82efaf5d8a994f001bc3b51f61652ee8448ad32b 100644 (file)
@@ -173,6 +173,12 @@ struct pipe_context {
                                      struct pipe_resource *resource,
                                      unsigned offset);
 
+   /**
+    * Set whether all current non-driver queries except TIME_ELAPSED are
+    * active or paused.
+    */
+   void (*set_active_query_state)(struct pipe_context *pipe, boolean enable);
+
    /*@}*/
 
    /**