Commit f2c48925 authored by Christian Gmeiner's avatar Christian Gmeiner Committed by Marge Bot
Browse files

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's avatarChristian Gmeiner <christian.gmeiner@gmail.com>
Part-of: <mesa/mesa!1530>
parent 46096a4c
......@@ -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);
......
......@@ -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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment