This adds a new group for MP performance counters and requires to write our own implementation of get_driver_query_group_info.
Signed-off-by: Samuel Pitoiset <samuel.pitoi...@gmail.com> --- src/gallium/drivers/nouveau/nvc0/nvc0_query.c | 52 ++++++++++++++++++++++++-- src/gallium/drivers/nouveau/nvc0/nvc0_screen.h | 5 +++ 2 files changed, 54 insertions(+), 3 deletions(-) diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c index 16e2a9d..cd11774 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_query.c +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_query.c @@ -24,8 +24,6 @@ #define NVC0_PUSH_EXPLICIT_SPACE_CHECKING -#include "util/u_query.h" - #include "nvc0/nvc0_context.h" #include "nv_object.xml.h" #include "nvc0/nve4_compute.xml.h" @@ -1412,6 +1410,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (id < NVC0_QUERY_DRV_STAT_COUNT) { info->name = nvc0_drv_stat_names[id]; info->query_type = NVC0_QUERY_DRV_STAT(id); + info->group_id = NVC0_QUERY_DRV_STAT_GROUP; info->max_value.u64 = ~0ULL; info->uses_byte_units = !!strstr(info->name, "bytes"); return 1; @@ -1421,6 +1420,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (screen->base.class_3d >= NVE4_3D_CLASS) { info->name = nve4_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; info->query_type = NVE4_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); + info->group_id = NVC0_QUERY_PM_GROUP; info->max_value.u64 = (id < NVE4_PM_QUERY_METRIC_MP_OCCUPANCY) ? ~0ULL : 100; info->uses_byte_units = FALSE; @@ -1429,6 +1429,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, if (screen->compute) { info->name = nvc0_pm_query_names[id - NVC0_QUERY_DRV_STAT_COUNT]; info->query_type = NVC0_PM_QUERY(id - NVC0_QUERY_DRV_STAT_COUNT); + info->group_id = NVC0_QUERY_PM_GROUP; info->max_value.u64 = ~0ULL; info->uses_byte_units = FALSE; return 1; @@ -1437,6 +1438,7 @@ nvc0_screen_get_driver_query_info(struct pipe_screen *pscreen, /* user asked for info about non-existing query */ info->name = "this_is_not_the_query_you_are_looking_for"; info->query_type = 0xdeadd01d; + info->group_id = 0; info->max_value.u64 = 0; info->uses_byte_units = FALSE; return 0; @@ -1447,7 +1449,51 @@ nvc0_screen_get_driver_query_group_info(struct pipe_screen *pscreen, unsigned id, struct pipe_driver_query_group_info *info) { - return util_get_driver_query_group_info(id, 29, info); + struct nvc0_screen *screen = nvc0_screen(pscreen); + int count = 0; + +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + count++; +#endif + if (screen->base.device->drm_version >= 0x01000101) { + if (screen->base.class_3d >= NVE4_3D_CLASS) { + count++; + } else + if (screen->compute) { + count++; /* NVC0_COMPUTE is not always enabled */ + } + } + + if (!info) + return count; + +#ifdef NOUVEAU_ENABLE_DRIVER_STATISTICS + if (id == NVC0_QUERY_DRV_STAT_GROUP) { + info->name = "Driver statistics"; + info->max_active_queries = 8; + info->num_queries = NVC0_QUERY_DRV_STAT_COUNT; + return 1; + } else +#endif + if (id == NVC0_QUERY_PM_GROUP) { + info->name = "Performance counters"; + info->max_active_queries = 8; /* 8 MP counters for NVC0+ */ + + if (screen->base.class_3d >= NVE4_3D_CLASS) { + info->num_queries = NVE4_PM_QUERY_COUNT; + return 1; + } else + if (screen->compute) { + info->num_queries = NVC0_PM_QUERY_COUNT; + return 1; + } + } + + /* user asked for info about non-existing query group */ + info->name = "this_is_not_the_query_group_you_are_looking_for"; + info->max_active_queries = 0; + info->num_queries = 0; + return 0; } void diff --git a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h index be9b1c8..405187c 100644 --- a/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h +++ b/src/gallium/drivers/nouveau/nvc0/nvc0_screen.h @@ -88,6 +88,11 @@ nvc0_screen(struct pipe_screen *screen) return (struct nvc0_screen *)screen; } +/* + * Performance counter groups: + */ +#define NVC0_QUERY_DRV_STAT_GROUP 0 +#define NVC0_QUERY_PM_GROUP 1 /* Performance counter queries: */ -- 2.0.0 _______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev