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

etnaviv: convert perfmon queries to acc queries


Signed-off-by: Christian Gmeiner's avatarChristian Gmeiner <christian.gmeiner@gmail.com>
Tested-by: Marge Bot <mesa/mesa!1530>
Part-of: <mesa/mesa!1530>
parent 20e0ef88
......@@ -39,12 +39,11 @@ C_SOURCES := \
etnaviv_query.c \
etnaviv_query.h \
etnaviv_query_acc_occlusion.c \
etnaviv_query_acc_perfmon.c \
etnaviv_query_acc.c \
etnaviv_query_acc.h \
etnaviv_query_sw.c \
etnaviv_query_sw.h \
etnaviv_query_pm.c \
etnaviv_query_pm.h \
etnaviv_rasterizer.c \
etnaviv_rasterizer.h \
etnaviv_resource.c \
......
......@@ -29,10 +29,10 @@
#include "util/u_inlines.h"
#include "etnaviv_context.h"
#include "etnaviv_perfmon.h"
#include "etnaviv_query.h"
#include "etnaviv_query_acc.h"
#include "etnaviv_query_sw.h"
#include "etnaviv_query_pm.h"
static struct pipe_query *
etna_create_query(struct pipe_context *pctx, unsigned query_type,
......@@ -44,8 +44,6 @@ etna_create_query(struct pipe_context *pctx, unsigned query_type,
q = etna_sw_create_query(ctx, query_type);
if (!q)
q = etna_acc_create_query(ctx, query_type);
if (!q)
q = etna_pm_create_query(ctx, query_type);
return (struct pipe_query *)q;
}
......
......@@ -37,10 +37,12 @@
extern const struct etna_acc_sample_provider occlusion_provider;
extern const struct etna_acc_sample_provider perfmon_provider;
static const struct etna_acc_sample_provider *acc_sample_provider[] =
{
&occlusion_provider,
&perfmon_provider,
};
static void
......
......@@ -22,160 +22,145 @@
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rob Clark <robclark@freedesktop.org>
* Christian Gmeiner <christian.gmeiner@gmail.com>
*/
#include "util/u_memory.h"
#include "etnaviv_context.h"
#include "etnaviv_query_pm.h"
#include "etnaviv_screen.h"
#include "etnaviv_debug.h"
#include "etnaviv_emit.h"
#include "etnaviv_query_acc.h"
static inline void
etna_pm_add_signal(struct etna_pm_query *pq, struct etna_perfmon *perfmon,
const struct etna_perfmon_config *cfg)
struct etna_pm_query
{
struct etna_perfmon_signal *signal = etna_pm_query_signal(perfmon, cfg->source);
struct etna_acc_query base;
pq->signal = signal;
}
struct etna_perfmon_signal *signal;
unsigned sequence;
};
static bool
realloc_query_bo(struct etna_context *ctx, struct etna_pm_query *pq)
static inline struct etna_pm_query *
etna_pm_query(struct etna_acc_query *aq)
{
if (pq->bo)
etna_bo_del(pq->bo);
pq->bo = etna_bo_new(ctx->screen->dev, 64, DRM_ETNA_GEM_CACHE_WC);
if (unlikely(!pq->bo))
return false;
return (struct etna_pm_query *)aq;
}
pq->data = etna_bo_map(pq->bo);
static inline void
pm_add_signal(struct etna_pm_query *pq, struct etna_perfmon *perfmon,
const struct etna_perfmon_config *cfg)
{
struct etna_perfmon_signal *signal = etna_pm_query_signal(perfmon, cfg->source);
return true;
pq->signal = signal;
}
static void
etna_pm_query_get(struct etna_cmd_stream *stream, struct etna_query *q,
unsigned flags)
pm_query(struct etna_context *ctx, struct etna_acc_query *aq, unsigned flags)
{
struct etna_pm_query *pq = etna_pm_query(q);
struct etna_cmd_stream *stream = ctx->stream;
struct etna_pm_query *pq = etna_pm_query(aq);
unsigned offset;
assert(flags);
if (flags == ETNA_PM_PROCESS_PRE)
offset = 1;
else
offset = 2;
if (aq->samples > 127) {
aq->samples = 127;
BUG("samples overflow perfmon");
}
/* offset 0 is reserved for seq number */
offset = 1 + aq->samples;
pq->sequence++;
/* skip seq number of 0 as the buffer got zeroed out */
pq->sequence = MAX2(pq->sequence, 1);
struct etna_perf p = {
.flags = flags,
.sequence = pq->sequence,
.bo = pq->bo,
.bo = etna_resource(aq->prsc)->bo,
.signal = pq->signal,
.offset = offset
};
etna_cmd_stream_perf(stream, &p);
resource_written(ctx, aq->prsc);
/* force a flush in !wait case in etna_acc_get_query_result(..) */
aq->no_wait_cnt = 10;
}
static inline void
etna_pm_query_update(struct etna_query *q)
static bool
perfmon_supports(unsigned query_type)
{
struct etna_pm_query *pq = etna_pm_query(q);
if (pq->data[0] == pq->sequence)
pq->ready = true;
return !!etna_pm_query_config(query_type);
}
static void
etna_pm_destroy_query(struct etna_context *ctx, struct etna_query *q)
static struct etna_acc_query *
perfmon_allocate(struct etna_context *ctx, unsigned query_type)
{
struct etna_pm_query *pq = etna_pm_query(q);
struct etna_pm_query *pq = CALLOC_STRUCT(etna_pm_query);
const struct etna_perfmon_config *cfg;
etna_bo_del(pq->bo);
FREE(pq);
}
if (!pq)
return NULL;
static bool
etna_pm_begin_query(struct etna_context *ctx, struct etna_query *q)
{
struct etna_pm_query *pq = etna_pm_query(q);
cfg = etna_pm_query_config(query_type);
if (!cfg)
return false;
pq->ready = false;
pq->sequence++;
if (!etna_pm_cfg_supported(ctx->screen->perfmon, cfg))
return false;
etna_pm_query_get(ctx->stream, q, ETNA_PM_PROCESS_PRE);
pm_add_signal(pq, ctx->screen->perfmon, cfg);
return true;
return &pq->base;
}
static void
etna_pm_end_query(struct etna_context *ctx, struct etna_query *q)
perfmon_resume(struct etna_acc_query *aq, struct etna_context *ctx)
{
etna_pm_query_get(ctx->stream, q, ETNA_PM_PROCESS_POST);
pm_query(ctx, aq, ETNA_PM_PROCESS_PRE);
}
static void
perfmon_suspend(struct etna_acc_query *aq, struct etna_context *ctx)
{
pm_query(ctx, aq, ETNA_PM_PROCESS_POST);
}
static bool
etna_pm_get_query_result(struct etna_context *ctx, struct etna_query *q,
bool wait, union pipe_query_result *result)
perfmon_result(struct etna_acc_query *aq, void *buf,
union pipe_query_result *result)
{
struct etna_pm_query *pq = etna_pm_query(q);
const struct etna_pm_query *pq = etna_pm_query(aq);
uint32_t sum = 0;
uint32_t *ptr = (uint32_t *)buf;
etna_pm_query_update(q);
/* check seq number */
if (pq->sequence > ptr[0])
return false;
if (!pq->ready) {
if (!wait)
return false;
/* jump over seq number */
ptr++;
if (!etna_bo_cpu_prep(pq->bo, DRM_ETNA_PREP_READ))
return false;
assert(aq->samples % 2 == 0);
pq->ready = true;
etna_bo_cpu_fini(pq->bo);
}
/* each pair has a start and end value */
for (unsigned i = 0; i < aq->samples; i += 2)
sum += *(ptr + i + 1) - *(ptr + i);
result->u32 = pq->data[2] - pq->data[1];
result->u32 = sum;
return true;
}
static const struct etna_query_funcs hw_query_funcs = {
.destroy_query = etna_pm_destroy_query,
.begin_query = etna_pm_begin_query,
.end_query = etna_pm_end_query,
.get_query_result = etna_pm_get_query_result,
const struct etna_acc_sample_provider perfmon_provider = {
.supports = perfmon_supports,
.allocate = perfmon_allocate,
.resume = perfmon_resume,
.suspend = perfmon_suspend,
.result = perfmon_result,
};
struct etna_query *
etna_pm_create_query(struct etna_context *ctx, unsigned query_type)
{
struct etna_perfmon *perfmon = ctx->screen->perfmon;
const struct etna_perfmon_config *cfg;
struct etna_pm_query *pq;
struct etna_query *q;
cfg = etna_pm_query_config(query_type);
if (!cfg)
return NULL;
if (!etna_pm_cfg_supported(perfmon, cfg))
return NULL;
pq = CALLOC_STRUCT(etna_pm_query);
if (!pq)
return NULL;
if (!realloc_query_bo(ctx, pq)) {
FREE(pq);
return NULL;
}
q = &pq->base;
q->funcs = &hw_query_funcs;
q->type = query_type;
etna_pm_add_signal(pq, perfmon, cfg);
return q;
}
/*
* Copyright (c) 2017 Etnaviv Project
* Copyright (C) 2017 Zodiac Inflight Innovations
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* to deal in the Software without restriction, including without limitation
* the rights to use, copy, modify, merge, publish, distribute, sub license,
* and/or sell copies of the Software, and to permit persons to whom the
* Software is furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice (including the
* next paragraph) shall be included in all copies or substantial portions
* of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
* THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
* FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
* DEALINGS IN THE SOFTWARE.
*
* Authors:
* Rob Clark <robclark@freedesktop.org>
* Christian Gmeiner <christian.gmeiner@gmail.com>
*/
#ifndef H_ETNAVIV_QUERY_PM
#define H_ETNAVIV_QUERY_PM
#include "etnaviv_perfmon.h"
#include "etnaviv_query.h"
struct etna_pm_query {
struct etna_query base;
struct etna_perfmon_signal *signal;
struct etna_bo *bo;
uint32_t *data;
uint32_t sequence;
bool ready;
};
static inline struct etna_pm_query *
etna_pm_query(struct etna_query *q)
{
return (struct etna_pm_query *)q;
}
struct etna_query *
etna_pm_create_query(struct etna_context *ctx, unsigned query_type);
#endif
......@@ -29,7 +29,7 @@
#define H_ETNAVIV_SCREEN
#include "etnaviv_internal.h"
#include "etnaviv_query_pm.h"
#include "etnaviv_perfmon.h"
#include "os/os_thread.h"
#include "pipe/p_screen.h"
......
......@@ -58,12 +58,11 @@ files_etnaviv = files(
'etnaviv_query.c',
'etnaviv_query.h',
'etnaviv_query_acc_occlusion.c',
'etnaviv_query_acc_perfmon.c',
'etnaviv_query_acc.c',
'etnaviv_query_acc.h',
'etnaviv_query_sw.c',
'etnaviv_query_sw.h',
'etnaviv_query_pm.c',
'etnaviv_query_pm.h',
'etnaviv_rasterizer.c',
'etnaviv_rasterizer.h',
'etnaviv_resource.c',
......
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