Mesa (master): freedreno: a bit of query refactor
Rob Clark
robclark at kemper.freedesktop.org
Sat Apr 22 14:11:27 UTC 2017
Module: Mesa
Branch: master
Commit: 935623af141930db8cbe1089e448cde4066da114
URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=935623af141930db8cbe1089e448cde4066da114
Author: Rob Clark <robdclark at gmail.com>
Date: Fri Apr 21 11:31:20 2017 -0400
freedreno: a bit of query refactor
Move a bit more of the logic shared by all query types (active tracking,
etc) into common code. This avoids introducing a 3rd copy of that logic
for a5xx.
Signed-off-by: Rob Clark <robdclark at gmail.com>
---
src/gallium/drivers/freedreno/freedreno_context.h | 13 +++++++++
src/gallium/drivers/freedreno/freedreno_query.c | 28 ++++++++++++++++++-
src/gallium/drivers/freedreno/freedreno_query_hw.c | 32 ----------------------
src/gallium/drivers/freedreno/freedreno_query_sw.c | 7 -----
4 files changed, 40 insertions(+), 40 deletions(-)
diff --git a/src/gallium/drivers/freedreno/freedreno_context.h b/src/gallium/drivers/freedreno/freedreno_context.h
index fe685e1767..041e226056 100644
--- a/src/gallium/drivers/freedreno/freedreno_context.h
+++ b/src/gallium/drivers/freedreno/freedreno_context.h
@@ -381,8 +381,21 @@ fd_batch_set_stage(struct fd_batch *batch,
struct fd_ringbuffer *ring, enum fd_render_stage stage)
{
struct fd_context *ctx = batch->ctx;
+
+ /* special case: internal blits (like mipmap level generation)
+ * go through normal draw path (via util_blitter_blit()).. but
+ * we need to ignore the FD_STAGE_DRAW which will be set, so we
+ * don't enable queries which should be paused during internal
+ * blits:
+ */
+ if ((batch->stage == FD_STAGE_BLIT) &&
+ (stage != FD_STAGE_NULL))
+ return;
+
if (ctx->query_set_stage)
ctx->query_set_stage(batch, ring, stage);
+
+ batch->stage = stage;
}
void fd_context_setup_common_vbos(struct fd_context *ctx);
diff --git a/src/gallium/drivers/freedreno/freedreno_query.c b/src/gallium/drivers/freedreno/freedreno_query.c
index a27ddb5c63..0d7bc9f205 100644
--- a/src/gallium/drivers/freedreno/freedreno_query.c
+++ b/src/gallium/drivers/freedreno/freedreno_query.c
@@ -63,14 +63,34 @@ static boolean
fd_begin_query(struct pipe_context *pctx, struct pipe_query *pq)
{
struct fd_query *q = fd_query(pq);
- return q->funcs->begin_query(fd_context(pctx), q);
+ boolean ret;
+
+ if (q->active)
+ return false;
+
+ ret = q->funcs->begin_query(fd_context(pctx), q);
+ q->active = ret;
+
+ return ret;
}
static bool
fd_end_query(struct pipe_context *pctx, struct pipe_query *pq)
{
struct fd_query *q = fd_query(pq);
+
+ /* there are a couple special cases, which don't have
+ * a matching ->begin_query():
+ */
+ if (skip_begin_query(q->type) && !q->active)
+ fd_begin_query(pctx, pq);
+
+ if (!q->active)
+ return false;
+
q->funcs->end_query(fd_context(pctx), q);
+ q->active = false;
+
return true;
}
@@ -79,6 +99,12 @@ fd_get_query_result(struct pipe_context *pctx, struct pipe_query *pq,
boolean wait, union pipe_query_result *result)
{
struct fd_query *q = fd_query(pq);
+
+ if (q->active)
+ return false;
+
+ util_query_clear_result(result, q->type);
+
return q->funcs->get_query_result(fd_context(pctx), q, wait, result);
}
diff --git a/src/gallium/drivers/freedreno/freedreno_query_hw.c b/src/gallium/drivers/freedreno/freedreno_query_hw.c
index 470826a94c..ef458ce5db 100644
--- a/src/gallium/drivers/freedreno/freedreno_query_hw.c
+++ b/src/gallium/drivers/freedreno/freedreno_query_hw.c
@@ -162,17 +162,12 @@ fd_hw_begin_query(struct fd_context *ctx, struct fd_query *q)
DBG("%p: active=%d", q, q->active);
- if (q->active)
- return false;
-
/* begin_query() should clear previous results: */
destroy_periods(ctx, hq);
if (batch && is_active(hq, batch->stage))
resume_query(batch, hq, batch->draw);
- q->active = true;
-
/* add to active list: */
assert(list_empty(&hq->list));
list_addtail(&hq->list, &ctx->active_queries);
@@ -186,22 +181,11 @@ fd_hw_end_query(struct fd_context *ctx, struct fd_query *q)
struct fd_batch *batch = ctx->batch;
struct fd_hw_query *hq = fd_hw_query(q);
- /* there are a couple special cases, which don't have
- * a matching ->begin_query():
- */
- if (skip_begin_query(q->type) && !q->active) {
- fd_hw_begin_query(ctx, q);
- }
-
DBG("%p: active=%d", q, q->active);
- if (!q->active)
- return;
-
if (batch && is_active(hq, batch->stage))
pause_query(batch, hq, batch->draw);
- q->active = false;
/* remove from active list: */
list_delinit(&hq->list);
}
@@ -222,11 +206,6 @@ fd_hw_get_query_result(struct fd_context *ctx, struct fd_query *q,
DBG("%p: wait=%d, active=%d", q, wait, q->active);
- if (q->active)
- return false;
-
- util_query_clear_result(result, q->type);
-
if (LIST_IS_EMPTY(&hq->periods))
return true;
@@ -424,16 +403,6 @@ void
fd_hw_query_set_stage(struct fd_batch *batch, struct fd_ringbuffer *ring,
enum fd_render_stage stage)
{
- /* special case: internal blits (like mipmap level generation)
- * go through normal draw path (via util_blitter_blit()).. but
- * we need to ignore the FD_STAGE_DRAW which will be set, so we
- * don't enable queries which should be paused during internal
- * blits:
- */
- if ((batch->stage == FD_STAGE_BLIT) &&
- (stage != FD_STAGE_NULL))
- return;
-
if (stage != batch->stage) {
struct fd_hw_query *hq;
LIST_FOR_EACH_ENTRY(hq, &batch->ctx->active_queries, list) {
@@ -447,7 +416,6 @@ fd_hw_query_set_stage(struct fd_batch *batch, struct fd_ringbuffer *ring,
}
}
clear_sample_cache(batch);
- batch->stage = stage;
}
/* call the provider->enable() for all the hw queries that were active
diff --git a/src/gallium/drivers/freedreno/freedreno_query_sw.c b/src/gallium/drivers/freedreno/freedreno_query_sw.c
index 4af6a125e0..dfa8987239 100644
--- a/src/gallium/drivers/freedreno/freedreno_query_sw.c
+++ b/src/gallium/drivers/freedreno/freedreno_query_sw.c
@@ -89,7 +89,6 @@ static boolean
fd_sw_begin_query(struct fd_context *ctx, struct fd_query *q)
{
struct fd_sw_query *sq = fd_sw_query(q);
- q->active = true;
sq->begin_value = read_counter(ctx, q->type);
if (is_rate_query(q))
sq->begin_time = os_time_get();
@@ -100,7 +99,6 @@ static void
fd_sw_end_query(struct fd_context *ctx, struct fd_query *q)
{
struct fd_sw_query *sq = fd_sw_query(q);
- q->active = false;
sq->end_value = read_counter(ctx, q->type);
if (is_rate_query(q))
sq->end_time = os_time_get();
@@ -112,11 +110,6 @@ fd_sw_get_query_result(struct fd_context *ctx, struct fd_query *q,
{
struct fd_sw_query *sq = fd_sw_query(q);
- if (q->active)
- return false;
-
- util_query_clear_result(result, q->type);
-
result->u64 = sq->end_value - sq->begin_value;
if (is_rate_query(q)) {
More information about the mesa-commit
mailing list