mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2026-05-05 03:08:05 +02:00
v3d: Switch to use libbroadcom_perfcntrs
Switch to a common library that does all the performance counter readout. This converts one version-dependend file to a generic one. Signed-off-by: Christian Gmeiner <cgmeiner@igalia.com> Reviewed-by: Maíra Canal <mcanal@igalia.com> Part-of: <https://gitlab.freedesktop.org/mesa/mesa/-/merge_requests/32277>
This commit is contained in:
parent
e531e9d616
commit
bb3fc7a44f
7 changed files with 50 additions and 111 deletions
|
|
@ -16,6 +16,7 @@ files_libv3d = files(
|
|||
'v3d_program.c',
|
||||
'v3d_query.c',
|
||||
'v3d_query.h',
|
||||
'v3d_query_perfcnt.c',
|
||||
'v3d_query_pipe.c',
|
||||
'v3d_resource.c',
|
||||
'v3d_resource.h',
|
||||
|
|
@ -29,7 +30,6 @@ files_per_version = files(
|
|||
'v3dx_emit.c',
|
||||
'v3dx_format_table.c',
|
||||
'v3dx_job.c',
|
||||
'v3dx_query_perfcnt.c',
|
||||
'v3dx_rcl.c',
|
||||
'v3dx_state.c',
|
||||
'v3dx_tfu.c',
|
||||
|
|
@ -78,5 +78,5 @@ libv3d = static_library(
|
|||
driver_v3d = declare_dependency(
|
||||
compile_args : '-DGALLIUM_V3D',
|
||||
link_with : [libv3d, libv3dwinsys, libbroadcom_cle, libbroadcom_v3d],
|
||||
dependencies : idep_nir,
|
||||
dependencies : [idep_nir, idep_broadcom_perfcntrs],
|
||||
)
|
||||
|
|
|
|||
|
|
@ -28,11 +28,21 @@ v3d_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned index,
|
|||
struct pipe_driver_query_group_info *info)
|
||||
{
|
||||
struct v3d_screen *screen = v3d_screen(pscreen);
|
||||
struct v3d_device_info *devinfo = &screen->devinfo;
|
||||
|
||||
return v3d_X(devinfo, get_driver_query_group_info_perfcnt)(screen,
|
||||
index,
|
||||
info);
|
||||
if (!screen->has_perfmon)
|
||||
return 0;
|
||||
|
||||
if (!info)
|
||||
return 1;
|
||||
|
||||
if (index > 0)
|
||||
return 0;
|
||||
|
||||
info->name = "V3D counters";
|
||||
info->max_active_queries = DRM_V3D_MAX_PERF_COUNTERS;
|
||||
info->num_queries = screen->perfcnt->max_perfcnt;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
|
|
@ -40,11 +50,26 @@ v3d_get_driver_query_info(struct pipe_screen *pscreen, unsigned index,
|
|||
struct pipe_driver_query_info *info)
|
||||
{
|
||||
struct v3d_screen *screen = v3d_screen(pscreen);
|
||||
struct v3d_device_info *devinfo = &screen->devinfo;
|
||||
struct v3d_perfcntr_desc *desc;
|
||||
|
||||
return v3d_X(devinfo, get_driver_query_info_perfcnt)(screen,
|
||||
index,
|
||||
info);
|
||||
if (!screen->has_perfmon)
|
||||
return 0;
|
||||
|
||||
if (!info)
|
||||
return screen->perfcnt->max_perfcnt;
|
||||
|
||||
desc = v3d_perfcntrs_get_by_index(screen->perfcnt, index);
|
||||
if (!desc)
|
||||
return 0;
|
||||
|
||||
info->name = desc->name;
|
||||
info->group_id = 0;
|
||||
info->query_type = PIPE_QUERY_DRIVER_SPECIFIC + index;
|
||||
info->result_type = PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE;
|
||||
info->type = PIPE_DRIVER_QUERY_TYPE_UINT64;
|
||||
info->flags = PIPE_DRIVER_QUERY_FLAG_BATCH;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static struct pipe_query *
|
||||
|
|
@ -60,12 +85,8 @@ v3d_create_batch_query(struct pipe_context *pctx, unsigned num_queries,
|
|||
unsigned *query_types)
|
||||
{
|
||||
struct v3d_context *v3d = v3d_context(pctx);
|
||||
struct v3d_screen *screen = v3d->screen;
|
||||
struct v3d_device_info *devinfo = &screen->devinfo;
|
||||
|
||||
return v3d_X(devinfo, create_batch_query_perfcnt)(v3d_context(pctx),
|
||||
num_queries,
|
||||
query_types);
|
||||
return v3d_create_batch_query_pipe(v3d, num_queries, query_types);
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
|
|||
|
|
@ -42,5 +42,7 @@ struct v3d_query
|
|||
};
|
||||
|
||||
struct pipe_query *v3d_create_query_pipe(struct v3d_context *v3d, unsigned query_type, unsigned index);
|
||||
struct pipe_query *v3d_create_batch_query_pipe(struct v3d_context *v3d, unsigned num_queries,
|
||||
unsigned *query_types);
|
||||
|
||||
#endif /* V3D_QUERY_H */
|
||||
|
|
|
|||
|
|
@ -28,8 +28,7 @@
|
|||
*/
|
||||
|
||||
#include "v3d_query.h"
|
||||
|
||||
#include "common/v3d_performance_counters.h"
|
||||
#include "v3d_screen.h"
|
||||
|
||||
struct v3d_query_perfcnt
|
||||
{
|
||||
|
|
@ -51,77 +50,6 @@ kperfmon_destroy(struct v3d_context *v3d, struct v3d_perfmon_state *perfmon)
|
|||
perfmon->kperfmon_id, strerror(errno));
|
||||
}
|
||||
|
||||
int
|
||||
v3dX(get_driver_query_group_info_perfcnt)(struct v3d_screen *screen, unsigned index,
|
||||
struct pipe_driver_query_group_info *info)
|
||||
{
|
||||
struct v3d_device_info *devinfo = &screen->devinfo;
|
||||
|
||||
if (!screen->has_perfmon)
|
||||
return 0;
|
||||
|
||||
if (!info)
|
||||
return 1;
|
||||
|
||||
if (index > 0)
|
||||
return 0;
|
||||
|
||||
info->name = "V3D counters";
|
||||
info->max_active_queries = DRM_V3D_MAX_PERF_COUNTERS;
|
||||
info->num_queries = devinfo->max_perfcnt ? devinfo->max_perfcnt
|
||||
: ARRAY_SIZE(v3d_performance_counters);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int
|
||||
v3dX(get_driver_query_info_perfcnt)(struct v3d_screen *screen, unsigned index,
|
||||
struct pipe_driver_query_info *info)
|
||||
{
|
||||
struct v3d_device_info *devinfo = &screen->devinfo;
|
||||
unsigned max_perfcnt = devinfo->max_perfcnt ? devinfo->max_perfcnt
|
||||
: ARRAY_SIZE(v3d_performance_counters);
|
||||
|
||||
if (!screen->has_perfmon)
|
||||
return 0;
|
||||
|
||||
if (!info)
|
||||
return max_perfcnt;
|
||||
|
||||
if (index >= max_perfcnt)
|
||||
return 0;
|
||||
|
||||
if (screen->perfcnt_names) {
|
||||
if (screen->perfcnt_names[index]) {
|
||||
info->name = screen->perfcnt_names[index];
|
||||
} else {
|
||||
struct drm_v3d_perfmon_get_counter counter = {
|
||||
.counter = index,
|
||||
};
|
||||
int ret = v3d_ioctl(screen->fd, DRM_IOCTL_V3D_PERFMON_GET_COUNTER, &counter);
|
||||
if (ret != 0) {
|
||||
fprintf(stderr, "Failed to get performance counter %d: %s\n",
|
||||
index, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
screen->perfcnt_names[index] = ralloc_strdup(screen->perfcnt_names,
|
||||
(const char *) counter.name);
|
||||
info->name = screen->perfcnt_names[index];
|
||||
}
|
||||
} else {
|
||||
info->name = v3d_performance_counters[index][V3D_PERFCNT_NAME];
|
||||
}
|
||||
|
||||
info->group_id = 0;
|
||||
info->query_type = PIPE_QUERY_DRIVER_SPECIFIC + index;
|
||||
info->result_type = PIPE_DRIVER_QUERY_RESULT_TYPE_CUMULATIVE;
|
||||
info->type = PIPE_DRIVER_QUERY_TYPE_UINT64;
|
||||
info->flags = PIPE_DRIVER_QUERY_FLAG_BATCH;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
v3d_destroy_query_perfcnt(struct v3d_context *v3d, struct v3d_query *query)
|
||||
{
|
||||
|
|
@ -259,15 +187,14 @@ static const struct v3d_query_funcs perfcnt_query_funcs = {
|
|||
};
|
||||
|
||||
struct pipe_query *
|
||||
v3dX(create_batch_query_perfcnt)(struct v3d_context *v3d, unsigned num_queries,
|
||||
unsigned *query_types)
|
||||
v3d_create_batch_query_pipe(struct v3d_context *v3d, unsigned num_queries,
|
||||
unsigned *query_types)
|
||||
{
|
||||
struct v3d_screen *screen = v3d->screen;
|
||||
struct v3d_query_perfcnt *pquery = NULL;
|
||||
struct v3d_query *query;
|
||||
struct v3d_perfmon_state *perfmon = NULL;
|
||||
struct v3d_device_info *devinfo = &v3d->screen->devinfo;
|
||||
unsigned max_perfcnt = devinfo->max_perfcnt ? devinfo->max_perfcnt
|
||||
: ARRAY_SIZE(v3d_performance_counters);
|
||||
unsigned max_perfcnt = screen->perfcnt->max_perfcnt;
|
||||
int i;
|
||||
|
||||
/* Validate queries */
|
||||
|
|
@ -76,8 +76,8 @@ v3d_screen_destroy(struct pipe_screen *pscreen)
|
|||
{
|
||||
struct v3d_screen *screen = v3d_screen(pscreen);
|
||||
|
||||
ralloc_free(screen->perfcnt_names);
|
||||
screen->perfcnt_names = NULL;
|
||||
v3d_perfcntrs_fini(screen->perfcnt);
|
||||
screen->perfcnt = NULL;
|
||||
|
||||
_mesa_hash_table_destroy(screen->bo_handles, NULL);
|
||||
v3d_bufmgr_destroy(pscreen);
|
||||
|
|
@ -944,14 +944,9 @@ v3d_screen_create(int fd, const struct pipe_screen_config *config,
|
|||
if (!v3d_get_device_info(screen->fd, &screen->devinfo, &v3d_ioctl))
|
||||
goto fail;
|
||||
|
||||
const uint8_t max_perfcnt = screen->devinfo.max_perfcnt;
|
||||
if (max_perfcnt) {
|
||||
screen->perfcnt_names = rzalloc_array(screen, char*, max_perfcnt);
|
||||
if (!screen->perfcnt_names) {
|
||||
fprintf(stderr, "Error allocating performance counters names");
|
||||
goto fail;
|
||||
}
|
||||
}
|
||||
screen->perfcnt = v3d_perfcntrs_init(&screen->devinfo, screen->fd);
|
||||
if (!screen->perfcnt)
|
||||
goto fail;
|
||||
|
||||
driParseConfigFiles(config->options, config->options_info, 0, "v3d",
|
||||
NULL, NULL, NULL, 0, NULL, 0);
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@
|
|||
#include "util/slab.h"
|
||||
#include "broadcom/common/v3d_debug.h"
|
||||
#include "broadcom/common/v3d_device_info.h"
|
||||
#include "broadcom/perfcntrs/v3d_perfcntrs.h"
|
||||
|
||||
struct v3d_bo;
|
||||
|
||||
|
|
@ -58,8 +59,7 @@ struct v3d_screen {
|
|||
|
||||
const char *name;
|
||||
|
||||
/** Stores performance counters names **/
|
||||
char **perfcnt_names;
|
||||
struct v3d_perfcntrs *perfcnt;
|
||||
|
||||
struct slab_parent_pool transfer_pool;
|
||||
|
||||
|
|
|
|||
|
|
@ -63,12 +63,6 @@ bool v3dX(tfu)(struct pipe_context *pctx,
|
|||
unsigned int dst_layer,
|
||||
bool for_mipmap);
|
||||
|
||||
int v3dX(get_driver_query_group_info_perfcnt)(struct v3d_screen *screen,
|
||||
unsigned index,
|
||||
struct pipe_driver_query_group_info *info);
|
||||
int v3dX(get_driver_query_info_perfcnt)(struct v3d_screen *screen,
|
||||
unsigned index,
|
||||
struct pipe_driver_query_info *info);
|
||||
struct pipe_query *v3dX(create_batch_query_perfcnt)(struct v3d_context *v3d,
|
||||
unsigned num_queries,
|
||||
unsigned *query_types);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue