X-Git-Url: https://git.cworth.org/git?p=fips;a=blobdiff_plain;f=context.c;h=6bc3e0af7365e0ec104073a146ba5b2e6b78d5fb;hp=133c37c168d6b04016579cbf3ccbd3938f11e241;hb=ba91fa6199a75aea42e40221489d259f1f723e4e;hpb=c27d7ce0b3ce5a2b9b753a654fdebcc1627aae52 diff --git a/context.c b/context.c index 133c37c..6bc3e0a 100644 --- a/context.c +++ b/context.c @@ -28,12 +28,18 @@ typedef struct context /* Pointer to the system's context ID, (such as a GLXContext) */ void *system_id; + /* Does this context have the AMD_performance_monitor extension? */ + bool have_perfmon; + metrics_info_t metrics_info; metrics_t *metrics; } context_t; context_t *current_context; +static bool +check_extension (const char *extension); + static context_t * context_create (fips_api_t api, void *system_context_id) { @@ -45,7 +51,9 @@ context_create (fips_api_t api, void *system_context_id) fips_dispatch_init (api); - metrics_info_init (&ctx->metrics_info); + ctx->have_perfmon = check_extension ("AMD_performance_monitor"); + + metrics_info_init (&ctx->metrics_info, ctx->have_perfmon); ctx->metrics = metrics_create (&ctx->metrics_info); return ctx; @@ -115,3 +123,22 @@ context_end_frame (void) { return metrics_end_frame (current_context->metrics); } + +/* Is the given extension available? */ +static bool +check_extension (const char *extension) +{ + int i, num_extensions; + const char *available; + + glGetIntegerv (GL_NUM_EXTENSIONS, &num_extensions); + + for (i = 0; i < num_extensions; i++) { + available = (char *) glGetStringi (GL_EXTENSIONS, i); + if (strcmp (extension, available) == 0) { + return true; + } + } + + return false; +}