[Mesa-dev] [PATCH v3 05/10] gallium: make pipe_context::begin_query return a boolean
Martin Peres
martin.peres at free.fr
Sun Apr 26 14:41:16 PDT 2015
On 02/04/2015 21:41, Samuel Pitoiset wrote:
> GL_AMD_performance_monitor must return an error when a monitoring
> session cannot be started.
>
> Signed-off-by: Samuel Pitoiset <samuel.pitoiset at gmail.com>
> Reviewed-by: Marek Olšák <marek.olsak at amd.com>
> Reviewed-by: Martin Peres <martin.peres at free.fr>
> ---
> src/gallium/drivers/freedreno/freedreno_query.c | 4 ++--
> src/gallium/drivers/freedreno/freedreno_query.h | 2 +-
> src/gallium/drivers/freedreno/freedreno_query_hw.c | 3 ++-
> src/gallium/drivers/freedreno/freedreno_query_sw.c | 3 ++-
> src/gallium/drivers/i915/i915_query.c | 3 ++-
> src/gallium/drivers/ilo/ilo_query.c | 3 ++-
> src/gallium/drivers/llvmpipe/lp_query.c | 3 ++-
> src/gallium/drivers/noop/noop_pipe.c | 3 ++-
> src/gallium/drivers/nouveau/nv30/nv30_query.c | 5 +++--
> src/gallium/drivers/nouveau/nv50/nv50_query.c | 3 ++-
> src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 3 ++-
> src/gallium/drivers/r300/r300_query.c | 9 +++++----
> src/gallium/drivers/radeon/r600_query.c | 16 +++++++++-------
> src/gallium/drivers/rbug/rbug_context.c | 8 +++++---
> src/gallium/drivers/softpipe/sp_query.c | 3 ++-
> src/gallium/drivers/svga/svga_pipe_query.c | 3 ++-
> src/gallium/drivers/trace/tr_context.c | 6 ++++--
> src/gallium/include/pipe/p_context.h | 2 +-
> 18 files changed, 50 insertions(+), 32 deletions(-)
>
> diff --git a/src/gallium/drivers/freedreno/freedreno_query.c b/src/gallium/drivers/freedreno/freedreno_query.c
> index 6f01e03..db2683c 100644
> --- a/src/gallium/drivers/freedreno/freedreno_query.c
> +++ b/src/gallium/drivers/freedreno/freedreno_query.c
> @@ -59,11 +59,11 @@ fd_destroy_query(struct pipe_context *pctx, struct pipe_query *pq)
> q->funcs->destroy_query(fd_context(pctx), q);
> }
>
> -static void
> +static boolean
> fd_begin_query(struct pipe_context *pctx, struct pipe_query *pq)
> {
> struct fd_query *q = fd_query(pq);
> - q->funcs->begin_query(fd_context(pctx), q);
> + return q->funcs->begin_query(fd_context(pctx), q);
> }
>
> static void
> diff --git a/src/gallium/drivers/freedreno/freedreno_query.h b/src/gallium/drivers/freedreno/freedreno_query.h
> index bc9a7a2..c2c71da 100644
> --- a/src/gallium/drivers/freedreno/freedreno_query.h
> +++ b/src/gallium/drivers/freedreno/freedreno_query.h
> @@ -37,7 +37,7 @@ struct fd_query;
> struct fd_query_funcs {
> void (*destroy_query)(struct fd_context *ctx,
> struct fd_query *q);
> - void (*begin_query)(struct fd_context *ctx, struct fd_query *q);
> + boolean (*begin_query)(struct fd_context *ctx, struct fd_query *q);
> void (*end_query)(struct fd_context *ctx, struct fd_query *q);
> boolean (*get_query_result)(struct fd_context *ctx,
> struct fd_query *q, boolean wait,
> diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c
> index b29f9d4..a587178 100644
> --- a/src/gallium/drivers/freedreno/freedreno_query_hw.c
> +++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c
> @@ -136,7 +136,7 @@ fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q)
> {
> struct fd_hw_query *hq = fd_hw_query(q);
> if (q->active)
> - return;
> + return true;
Should this be false instead of true?
>
> /* begin_query() should clear previous results: */
> destroy_periods(ctx, &hq->periods);
> @@ -149,6 +149,7 @@ fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q)
> /* add to active list: */
> list_del(&hq->list);
> list_addtail(&hq->list, &ctx->active_queries);
> + return true;
> }
>
> static void
> diff --git a/src/gallium/drivers/freedreno/freedreno_query_sw.c b/src/gallium/drivers/freedreno/freedreno_query_sw.c
> index 8d81698..514df14 100644
> --- a/src/gallium/drivers/freedreno/freedreno_query_sw.c
> +++ b/src/gallium/drivers/freedreno/freedreno_query_sw.c
> @@ -85,7 +85,7 @@ is_rate_query(struct fd_query *q)
> }
> }
>
> -static void
> +static boolean
> fd_sw_begin_query(struct fd_context *ctx, struct fd_query *q)
> {
> struct fd_sw_query *sq = fd_sw_query(q);
> @@ -93,6 +93,7 @@ fd_sw_begin_query(struct fd_context *ctx, struct fd_query *q)
> sq->begin_value = read_counter(ctx, q->type);
> if (is_rate_query(q))
> sq->begin_time = os_time_get();
> + return true;
> }
>
> static void
> diff --git a/src/gallium/drivers/i915/i915_query.c b/src/gallium/drivers/i915/i915_query.c
> index 1500d97..78d67ce 100644
> --- a/src/gallium/drivers/i915/i915_query.c
> +++ b/src/gallium/drivers/i915/i915_query.c
> @@ -54,9 +54,10 @@ static void i915_destroy_query(struct pipe_context *ctx,
> FREE(query);
> }
>
> -static void i915_begin_query(struct pipe_context *ctx,
> +static boolean i915_begin_query(struct pipe_context *ctx,
> struct pipe_query *query)
> {
> + return true;
> }
>
> static void i915_end_query(struct pipe_context *ctx, struct pipe_query *query)
> diff --git a/src/gallium/drivers/ilo/ilo_query.c b/src/gallium/drivers/ilo/ilo_query.c
> index 7a2e503..25d82f8 100644
> --- a/src/gallium/drivers/ilo/ilo_query.c
> +++ b/src/gallium/drivers/ilo/ilo_query.c
> @@ -111,7 +111,7 @@ ilo_destroy_query(struct pipe_context *pipe, struct pipe_query *query)
> FREE(q);
> }
>
> -static void
> +static boolean
> ilo_begin_query(struct pipe_context *pipe, struct pipe_query *query)
> {
> struct ilo_query *q = ilo_query(query);
> @@ -124,6 +124,7 @@ ilo_begin_query(struct pipe_context *pipe, struct pipe_query *query)
> q->active = true;
>
> ilo_query_table[q->type].begin(ilo_context(pipe), q);
> + return true;
> }
>
> static void
> diff --git a/src/gallium/drivers/llvmpipe/lp_query.c b/src/gallium/drivers/llvmpipe/lp_query.c
> index 8f41f56..4f8bab6 100644
> --- a/src/gallium/drivers/llvmpipe/lp_query.c
> +++ b/src/gallium/drivers/llvmpipe/lp_query.c
> @@ -184,7 +184,7 @@ llvmpipe_get_query_result(struct pipe_context *pipe,
> }
>
>
> -static void
> +static boolean
> llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
> {
> struct llvmpipe_context *llvmpipe = llvmpipe_context( pipe );
> @@ -235,6 +235,7 @@ llvmpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
> default:
> break;
> }
> + return true;
> }
>
>
> diff --git a/src/gallium/drivers/noop/noop_pipe.c b/src/gallium/drivers/noop/noop_pipe.c
> index 6fb2277..aeec677 100644
> --- a/src/gallium/drivers/noop/noop_pipe.c
> +++ b/src/gallium/drivers/noop/noop_pipe.c
> @@ -58,8 +58,9 @@ static void noop_destroy_query(struct pipe_context *ctx, struct pipe_query *quer
> FREE(query);
> }
>
> -static void noop_begin_query(struct pipe_context *ctx, struct pipe_query *query)
> +static boolean noop_begin_query(struct pipe_context *ctx, struct pipe_query *query)
> {
> + return true;
> }
>
> static void noop_end_query(struct pipe_context *ctx, struct pipe_query *query)
> diff --git a/src/gallium/drivers/nouveau/nv30/nv30_query.c b/src/gallium/drivers/nouveau/nv30/nv30_query.c
> index ace2cdc..516ee83 100644
> --- a/src/gallium/drivers/nouveau/nv30/nv30_query.c
> +++ b/src/gallium/drivers/nouveau/nv30/nv30_query.c
> @@ -144,7 +144,7 @@ nv30_query_destroy(struct pipe_context *pipe, struct pipe_query *pq)
> FREE(pq);
> }
>
> -static void
> +static boolean
> nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
> {
> struct nv30_context *nv30 = nv30_context(pipe);
> @@ -160,7 +160,7 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
> }
> break;
> case PIPE_QUERY_TIMESTAMP:
> - return;
> + return true;
> default:
> BEGIN_NV04(push, NV30_3D(QUERY_RESET), 1);
> PUSH_DATA (push, q->report);
> @@ -171,6 +171,7 @@ nv30_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
> BEGIN_NV04(push, SUBC_3D(q->enable), 1);
> PUSH_DATA (push, 1);
> }
> + return true;
> }
>
> static void
> diff --git a/src/gallium/drivers/nouveau/nv50/nv50_query.c b/src/gallium/drivers/nouveau/nv50/nv50_query.c
> index e81ac5a..bf3e134 100644
> --- a/src/gallium/drivers/nouveau/nv50/nv50_query.c
> +++ b/src/gallium/drivers/nouveau/nv50/nv50_query.c
> @@ -138,7 +138,7 @@ nv50_query_get(struct nouveau_pushbuf *push, struct nv50_query *q,
> PUSH_DATA (push, get);
> }
>
> -static void
> +static boolean
> nv50_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
> {
> struct nv50_context *nv50 = nv50_context(pipe);
> @@ -201,6 +201,7 @@ nv50_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
> break;
> }
> q->ready = FALSE;
> + return true;
> }
>
> static void
> diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
> index 477ca80..01e7b37 100644
> --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
> +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c
> @@ -250,7 +250,7 @@ nvc0_query_rotate(struct nvc0_context *nvc0, struct nvc0_query *q)
> nvc0_query_allocate(nvc0, q, NVC0_QUERY_ALLOC_SPACE);
> }
>
> -static void
> +static boolean
> nvc0_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
> {
> struct nvc0_context *nvc0 = nvc0_context(pipe);
> @@ -332,6 +332,7 @@ nvc0_query_begin(struct pipe_context *pipe, struct pipe_query *pq)
> break;
> }
> q->state = NVC0_QUERY_STATE_ACTIVE;
> + return true;
> }
>
> static void
> diff --git a/src/gallium/drivers/r300/r300_query.c b/src/gallium/drivers/r300/r300_query.c
> index 2364f3d..01b83b8 100644
> --- a/src/gallium/drivers/r300/r300_query.c
> +++ b/src/gallium/drivers/r300/r300_query.c
> @@ -85,24 +85,25 @@ void r300_resume_query(struct r300_context *r300,
> r300_mark_atom_dirty(r300, &r300->query_start);
> }
>
> -static void r300_begin_query(struct pipe_context* pipe,
> - struct pipe_query* query)
> +static boolean r300_begin_query(struct pipe_context* pipe,
> + struct pipe_query* query)
> {
> struct r300_context* r300 = r300_context(pipe);
> struct r300_query* q = r300_query(query);
>
> if (q->type == PIPE_QUERY_GPU_FINISHED)
> - return;
> + return true;
>
> if (r300->query_current != NULL) {
> fprintf(stderr, "r300: begin_query: "
> "Some other query has already been started.\n");
> assert(0);
> - return;
> + return false;
> }
>
> q->num_results = 0;
> r300_resume_query(r300, q);
> + return true;
> }
>
> void r300_stop_query(struct r300_context *r300)
> diff --git a/src/gallium/drivers/radeon/r600_query.c b/src/gallium/drivers/radeon/r600_query.c
> index 6a35ab8..7647d50 100644
> --- a/src/gallium/drivers/radeon/r600_query.c
> +++ b/src/gallium/drivers/radeon/r600_query.c
> @@ -417,7 +417,8 @@ static void r600_destroy_query(struct pipe_context *ctx, struct pipe_query *quer
> FREE(query);
> }
>
> -static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
> +static boolean r600_begin_query(struct pipe_context *ctx,
> + struct pipe_query *query)
> {
> struct r600_common_context *rctx = (struct r600_common_context *)ctx;
> struct r600_query *rquery = (struct r600_query *)query;
> @@ -425,7 +426,7 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
>
> if (!r600_query_needs_begin(rquery->type)) {
> assert(0);
> - return;
> + return false;
> }
>
> /* Non-GPU queries. */
> @@ -434,22 +435,22 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
> return;
> case R600_QUERY_DRAW_CALLS:
> rquery->begin_result = rctx->num_draw_calls;
> - return;
> + return true;
> case R600_QUERY_REQUESTED_VRAM:
> case R600_QUERY_REQUESTED_GTT:
> case R600_QUERY_VRAM_USAGE:
> case R600_QUERY_GTT_USAGE:
> rquery->begin_result = 0;
> - return;
> + return true;
> case R600_QUERY_BUFFER_WAIT_TIME:
> rquery->begin_result = rctx->ws->query_value(rctx->ws, RADEON_BUFFER_WAIT_TIME_NS);
> - return;
> + return true;
> case R600_QUERY_NUM_CS_FLUSHES:
> rquery->begin_result = rctx->ws->query_value(rctx->ws, RADEON_NUM_CS_FLUSHES);
> - return;
> + return true;
> case R600_QUERY_NUM_BYTES_MOVED:
> rquery->begin_result = rctx->ws->query_value(rctx->ws, RADEON_NUM_BYTES_MOVED);
> - return;
> + return true;
> }
>
> /* Discard the old query buffers. */
> @@ -475,6 +476,7 @@ static void r600_begin_query(struct pipe_context *ctx, struct pipe_query *query)
> if (!r600_is_timer_query(rquery->type)) {
> LIST_ADDTAIL(&rquery->list, &rctx->active_nontimer_queries);
> }
> + return true;
> }
>
> static void r600_end_query(struct pipe_context *ctx, struct pipe_query *query)
> diff --git a/src/gallium/drivers/rbug/rbug_context.c b/src/gallium/drivers/rbug/rbug_context.c
> index 7a8226e..dcdb242 100644
> --- a/src/gallium/drivers/rbug/rbug_context.c
> +++ b/src/gallium/drivers/rbug/rbug_context.c
> @@ -164,17 +164,19 @@ rbug_destroy_query(struct pipe_context *_pipe,
> pipe_mutex_unlock(rb_pipe->call_mutex);
> }
>
> -static void
> +static boolean
> rbug_begin_query(struct pipe_context *_pipe,
> struct pipe_query *query)
> {
> struct rbug_context *rb_pipe = rbug_context(_pipe);
> struct pipe_context *pipe = rb_pipe->pipe;
> + boolean ret;
>
> pipe_mutex_lock(rb_pipe->call_mutex);
> - pipe->begin_query(pipe,
> - query);
> + ret = pipe->begin_query(pipe,
> + query);
> pipe_mutex_unlock(rb_pipe->call_mutex);
> + return ret;
> }
>
> static void
> diff --git a/src/gallium/drivers/softpipe/sp_query.c b/src/gallium/drivers/softpipe/sp_query.c
> index e2fc917..e773870 100644
> --- a/src/gallium/drivers/softpipe/sp_query.c
> +++ b/src/gallium/drivers/softpipe/sp_query.c
> @@ -83,7 +83,7 @@ softpipe_destroy_query(struct pipe_context *pipe, struct pipe_query *q)
> }
>
>
> -static void
> +static boolean
> softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
> {
> struct softpipe_context *softpipe = softpipe_context( pipe );
> @@ -130,6 +130,7 @@ softpipe_begin_query(struct pipe_context *pipe, struct pipe_query *q)
> }
> softpipe->active_query_count++;
> softpipe->dirty |= SP_NEW_QUERY;
> + return true;
> }
>
>
> diff --git a/src/gallium/drivers/svga/svga_pipe_query.c b/src/gallium/drivers/svga/svga_pipe_query.c
> index 756e2b8..a97a9c4 100644
> --- a/src/gallium/drivers/svga/svga_pipe_query.c
> +++ b/src/gallium/drivers/svga/svga_pipe_query.c
> @@ -166,7 +166,7 @@ svga_destroy_query(struct pipe_context *pipe, struct pipe_query *q)
> }
>
>
> -static void
> +static boolean
> svga_begin_query(struct pipe_context *pipe, struct pipe_query *q)
> {
> struct svga_screen *svgascreen = svga_screen(pipe->screen);
> @@ -222,6 +222,7 @@ svga_begin_query(struct pipe_context *pipe, struct pipe_query *q)
> default:
> assert(!"unexpected query type in svga_begin_query()");
> }
> + return true;
> }
>
>
> diff --git a/src/gallium/drivers/trace/tr_context.c b/src/gallium/drivers/trace/tr_context.c
> index e713aba..0b56517 100644
> --- a/src/gallium/drivers/trace/tr_context.c
> +++ b/src/gallium/drivers/trace/tr_context.c
> @@ -185,12 +185,13 @@ trace_context_destroy_query(struct pipe_context *_pipe,
> }
>
>
> -static INLINE void
> +static INLINE boolean
> trace_context_begin_query(struct pipe_context *_pipe,
> struct pipe_query *query)
> {
> struct trace_context *tr_ctx = trace_context(_pipe);
> struct pipe_context *pipe = tr_ctx->pipe;
> + boolean ret;
>
> query = trace_query_unwrap(query);
>
> @@ -199,9 +200,10 @@ trace_context_begin_query(struct pipe_context *_pipe,
> trace_dump_arg(ptr, pipe);
> trace_dump_arg(ptr, query);
>
> - pipe->begin_query(pipe, query);
> + ret = pipe->begin_query(pipe, query);
>
> trace_dump_call_end();
> + return ret;
> }
>
>
> diff --git a/src/gallium/include/pipe/p_context.h b/src/gallium/include/pipe/p_context.h
> index a4cae8e..adff67a 100644
> --- a/src/gallium/include/pipe/p_context.h
> +++ b/src/gallium/include/pipe/p_context.h
> @@ -115,7 +115,7 @@ struct pipe_context {
> void (*destroy_query)(struct pipe_context *pipe,
> struct pipe_query *q);
>
> - void (*begin_query)(struct pipe_context *pipe, struct pipe_query *q);
> + boolean (*begin_query)(struct pipe_context *pipe, struct pipe_query *q);
> void (*end_query)(struct pipe_context *pipe, struct pipe_query *q);
>
> /**
More information about the mesa-dev
mailing list