bool
-st_init_perfmon(struct st_context *st)
+st_have_perfmon(struct st_context *st)
{
+ struct pipe_screen *screen = st->pipe->screen;
+
+ if (!screen->get_driver_query_info || !screen->get_driver_query_group_info)
+ return false;
+
+ return screen->get_driver_query_group_info(screen, 0, NULL) != 0;
+}
+
+static void
+st_InitPerfMonitorGroups(struct gl_context *ctx)
+{
+ struct st_context *st = st_context(ctx);
struct gl_perf_monitor_state *perfmon = &st->ctx->PerfMonitor;
struct pipe_screen *screen = st->pipe->screen;
struct gl_perf_monitor_group *groups = NULL;
int num_counters, num_groups;
int gid, cid;
- if (!screen->get_driver_query_info || !screen->get_driver_query_group_info)
- return false;
-
/* Get the number of available queries. */
num_counters = screen->get_driver_query_info(screen, 0, NULL);
- if (!num_counters)
- return false;
/* Get the number of available groups. */
num_groups = screen->get_driver_query_group_info(screen, 0, NULL);
- if (num_groups)
- groups = CALLOC(num_groups, sizeof(*groups));
+ groups = CALLOC(num_groups, sizeof(*groups));
if (!groups)
- return false;
+ return;
stgroups = CALLOC(num_groups, sizeof(*stgroups));
if (!stgroups)
perfmon->Groups = groups;
st->perfmon = stgroups;
- return true;
+ return;
fail:
for (gid = 0; gid < num_groups; gid++) {
FREE(stgroups);
fail_only_groups:
FREE(groups);
- return false;
}
void
void st_init_perfmon_functions(struct dd_function_table *functions)
{
+ functions->InitPerfMonitorGroups = st_InitPerfMonitorGroups;
functions->NewPerfMonitor = st_NewPerfMonitor;
functions->DeletePerfMonitor = st_DeletePerfMonitor;
functions->BeginPerfMonitor = st_BeginPerfMonitor;
st_init_extensions(st->pipe->screen, &ctx->Const,
&ctx->Extensions, &st->options, ctx->Mesa_DXTn);
- if (st_init_perfmon(st)) {
+ if (st_have_perfmon(st)) {
/* GL_AMD_performance_monitor is only enabled when the underlying
* driver expose GPU hardware performance counters. */
ctx->Extensions.AMD_performance_monitor = GL_TRUE;