This removes one common use of context_t from the metrics.c code, so
we're one step closer to have clean interfaces here, (rather than
everybody reaching into a global context_ structure).
fips_dispatch_init (api);
metrics_info_init (&ctx->metrics_info);
fips_dispatch_init (api);
metrics_info_init (&ctx->metrics_info);
- ctx->metrics = metrics_create ();
+ ctx->metrics = metrics_create (&ctx->metrics_info);
+ /* Description of all available peformance counters, counter
+ * groups, their names and IDs, etc. */
+ metrics_info_t *info;
+
+ /* The current operation being measured. */
metrics_op_t op;
/* GL_TIME_ELAPSED query for which glEndQuery has not yet
metrics_op_t op;
/* GL_TIME_ELAPSED query for which glEndQuery has not yet
+metrics_create (metrics_info_t *info)
{
metrics_t *metrics;
metrics = xmalloc (sizeof (metrics_t));
{
metrics_t *metrics;
metrics = xmalloc (sizeof (metrics_t));
+ metrics->info = info;
+
metrics->op = 0;
metrics->timer_begun_id = 0;
metrics->op = 0;
metrics->timer_begun_id = 0;
glGenPerfMonitorsAMD (1, &metrics->monitor_begun_id);
glGenPerfMonitorsAMD (1, &metrics->monitor_begun_id);
- for (i = 0; i < ctx->metrics_info.num_groups; i++)
+ for (i = 0; i < metrics->info->num_groups; i++)
{
metrics_group_info_t *group;
int num_counters;
{
metrics_group_info_t *group;
int num_counters;
- group = &ctx->metrics_info.groups[i];
+ group = &metrics->info->groups[i];
num_counters = group->num_counters;
if (group->max_active_counters < group->num_counters)
num_counters = group->num_counters;
if (group->max_active_counters < group->num_counters)
static void
op_metrics_init (context_t *ctx, op_metrics_t *metrics, metrics_op_t op)
{
static void
op_metrics_init (context_t *ctx, op_metrics_t *metrics, metrics_op_t op)
{
- metrics_info_t *info = &ctx->metrics_info;
+ metrics_info_t *info = ctx->metrics->info;
unsigned i, j;
metrics->op = op;
unsigned i, j;
metrics->op = op;
p += sizeof(var);
context_t *ctx = context_get_current ();
p += sizeof(var);
context_t *ctx = context_get_current ();
- metrics_info_t *info = &ctx->metrics_info;
+ metrics_info_t *info = ctx->metrics->info;
op_metrics_t *metrics = ctx_get_op_metrics (ctx, op);
unsigned char *p = (unsigned char *) result;
op_metrics_t *metrics = ctx_get_op_metrics (ctx, op);
unsigned char *p = (unsigned char *) result;
per_stage_metrics_t *per_stage,
double total)
{
per_stage_metrics_t *per_stage,
double total)
{
- metrics_info_t *info = &ctx->metrics_info;
+ metrics_info_t *info = ctx->metrics->info;
op_metrics_t *metric = per_stage->metrics;
metrics_group_info_t *group;
const char *op_string;
op_metrics_t *metric = per_stage->metrics;
metrics_group_info_t *group;
const char *op_string;
{
context_t *ctx = context_get_current ();
metrics_t *metrics = ctx->metrics;
{
context_t *ctx = context_get_current ();
metrics_t *metrics = ctx->metrics;
- metrics_info_t *info = &ctx->metrics_info;
+ metrics_info_t *info = metrics->info;
unsigned num_shader_stages = info->num_shader_stages;
per_stage_metrics_t *sorted, *per_stage;
double total_time, op_cycles;
unsigned num_shader_stages = info->num_shader_stages;
per_stage_metrics_t *sorted, *per_stage;
double total_time, op_cycles;
{
context_t *ctx = context_get_current ();
metrics_t *metrics = ctx->metrics;
{
context_t *ctx = context_get_current ();
metrics_t *metrics = ctx->metrics;
- metrics_info_t *info = &ctx->metrics_info;
+ metrics_info_t *info = metrics->info;
unsigned i, j;
timer_query_t *timer, *timer_next;
monitor_t *monitor, *monitor_next;
unsigned i, j;
timer_query_t *timer, *timer_next;
monitor_t *monitor, *monitor_next;
#ifndef METRICS_H
#define METRICS_H
#ifndef METRICS_H
#define METRICS_H
+#include "metrics-info.h"
+
typedef enum
{
METRICS_OP_ACCUM,
typedef enum
{
METRICS_OP_ACCUM,
typedef struct metrics metrics_t;
typedef struct metrics metrics_t;
-/* Create a new metrics_t object for tracking metrics. */
+/* Create a new metrics_t object for tracking metrics, given the
+ * pre-initialized metrics_info_t* describing available counters. */
+metrics_create (metrics_info_t *info);
/* Free all internal resources of a metrics_t
*
/* Free all internal resources of a metrics_t
*