From f2c4892512732bbf08951a188e4a5774951d6f86 Mon Sep 17 00:00:00 2001 From: Christian Gmeiner Date: Fri, 26 Jul 2019 10:18:44 +0200 Subject: [PATCH] etnaviv: rework etna_acc_sample_provider Simplify the interface a sampler provider needs to implement. The start(..) and stop(..) functions got called by resume(..) and suspend(..) so lets get rid of start(..) and stop(..). Also the way we count and use samples is much easier to follow now. Signed-off-by: Christian Gmeiner Part-of: --- .../drivers/etnaviv/etnaviv_query_acc.c | 28 ++++++------------- .../drivers/etnaviv/etnaviv_query_acc.h | 6 ++-- 2 files changed, 11 insertions(+), 23 deletions(-) diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_acc.c b/src/gallium/drivers/etnaviv/etnaviv_query_acc.c index ff709ed58ac..6e6fb6599ca 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_query_acc.c +++ b/src/gallium/drivers/etnaviv/etnaviv_query_acc.c @@ -43,7 +43,7 @@ */ static void -occlusion_start(struct etna_acc_query *aq, struct etna_context *ctx) +occlusion_resume(struct etna_acc_query *aq, struct etna_context *ctx) { struct etna_resource *rsc = etna_resource(aq->prsc); struct etna_reloc r = { @@ -62,25 +62,12 @@ occlusion_start(struct etna_acc_query *aq, struct etna_context *ctx) } static void -occlusion_stop(struct etna_acc_query *aq, struct etna_context *ctx) +occlusion_suspend(struct etna_acc_query *aq, struct etna_context *ctx) { /* 0x1DF5E76 is the value used by blob - but any random value will work */ etna_set_state(ctx->stream, VIVS_GL_OCCLUSION_QUERY_CONTROL, 0x1DF5E76); } -static void -occlusion_suspend(struct etna_acc_query *aq, struct etna_context *ctx) -{ - occlusion_stop(aq, ctx); -} - -static void -occlusion_resume(struct etna_acc_query *aq, struct etna_context *ctx) -{ - aq->samples++; - occlusion_start(aq, ctx); -} - static void occlusion_result(struct etna_acc_query *aq, void *buf, union pipe_query_result *result) @@ -88,7 +75,7 @@ occlusion_result(struct etna_acc_query *aq, void *buf, uint64_t sum = 0; uint64_t *ptr = (uint64_t *)buf; - for (unsigned i = 0; i <= aq->samples; i++) + for (unsigned i = 0; i < aq->samples; i++) sum += *(ptr + i); if (aq->base.type == PIPE_QUERY_OCCLUSION_COUNTER) @@ -109,8 +96,6 @@ etna_acc_destroy_query(struct etna_context *ctx, struct etna_query *q) } static const struct etna_acc_sample_provider occlusion_provider = { - .start = occlusion_start, - .stop = occlusion_stop, .suspend = occlusion_suspend, .resume = occlusion_resume, .result = occlusion_result, @@ -147,7 +132,8 @@ etna_acc_begin_query(struct etna_context *ctx, struct etna_query *q) /* ->begin_query() discards previous results, so realloc bo */ realloc_query_bo(ctx, aq); - p->start(aq, ctx); + p->resume(aq, ctx); + aq->samples++; /* add to active list */ assert(list_is_empty(&aq->node)); @@ -162,7 +148,8 @@ etna_acc_end_query(struct etna_context *ctx, struct etna_query *q) struct etna_acc_query *aq = etna_acc_query(q); const struct etna_acc_sample_provider *p = aq->provider; - p->stop(aq, ctx); + p->suspend(aq, ctx); + aq->samples++; /* remove from active list */ list_delinit(&aq->node); @@ -208,6 +195,7 @@ etna_acc_get_query_result(struct etna_context *ctx, struct etna_query *q, void *ptr = etna_bo_map(rsc->bo); p->result(aq, ptr, result); + aq->samples = 0; etna_bo_cpu_fini(rsc->bo); diff --git a/src/gallium/drivers/etnaviv/etnaviv_query_acc.h b/src/gallium/drivers/etnaviv/etnaviv_query_acc.h index 3545c4810dc..5927d7da564 100644 --- a/src/gallium/drivers/etnaviv/etnaviv_query_acc.h +++ b/src/gallium/drivers/etnaviv/etnaviv_query_acc.h @@ -34,10 +34,8 @@ struct etna_acc_query; struct etna_acc_sample_provider { - void (*start)(struct etna_acc_query *aq, struct etna_context *ctx); - void (*stop)(struct etna_acc_query *aq, struct etna_context *ctx); - void (*suspend)(struct etna_acc_query *aq, struct etna_context *ctx); void (*resume)(struct etna_acc_query *aq, struct etna_context *ctx); + void (*suspend)(struct etna_acc_query *aq, struct etna_context *ctx); void (*result)(struct etna_acc_query *aq, void *buf, union pipe_query_result *result); @@ -72,6 +70,7 @@ etna_acc_query_suspend(struct etna_acc_query *aq, struct etna_context *ctx) return; p->suspend(aq, ctx); + aq->samples++; } static inline void @@ -83,6 +82,7 @@ etna_acc_query_resume(struct etna_acc_query *aq, struct etna_context *ctx) return; p->resume(aq, ctx); + aq->samples++; } #endif -- 2.30.2