1 /* Copyright © 2013, Intel Corporation
3 * Permission is hereby granted, free of charge, to any person obtaining a copy
4 * of this software and associated documentation files (the "Software"), to deal
5 * in the Software without restriction, including without limitation the rights
6 * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 * copies of the Software, and to permit persons to whom the Software is
8 * furnished to do so, subject to the following conditions:
10 * The above copyright notice and this permission notice shall be included in
11 * all copies or substantial portions of the Software.
13 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
26 /* FIXME: Need a map from integers to context objects and track the
27 * current context with glXMakeContextCurrent, eglMakeCurrent, etc. */
29 context_t current_context;
32 context_enter (fips_api_t api, void *system_context_id unused)
34 context_t *ctx = ¤t_context;
36 fips_dispatch_init (api);
38 metrics_info_init (&ctx->metrics_info);
40 metrics_set_current_op (METRICS_OP_SHADER + 0);
41 metrics_counter_start ();
47 context_t *ctx = ¤t_context;
48 timer_query_t *timer, *timer_next;
49 monitor_t *monitor, *monitor_next;
51 metrics_collect_available ();
53 if (ctx->timer_begun_id) {
54 glEndQuery (GL_TIME_ELAPSED);
55 glDeleteQueries (1, &ctx->timer_begun_id);
56 ctx->timer_begun_id = 0;
59 for (timer = ctx->timer_head;
63 glDeleteQueries (1, &timer->id);
64 timer_next = timer->next;
67 ctx->timer_head = NULL;
68 ctx->timer_tail = NULL;
70 if (ctx->monitor_begun_id) {
71 glEndPerfMonitorAMD (ctx->monitor_begun_id);
72 glDeletePerfMonitorsAMD (1, &ctx->monitor_begun_id);
73 ctx->monitor_begun_id = 0;
76 for (monitor = ctx->monitor_head;
78 monitor = monitor_next)
80 glDeletePerfMonitorsAMD (1, &monitor->id);
81 monitor_next = monitor->next;
84 ctx->monitor_head = NULL;
85 ctx->monitor_tail = NULL;
87 current_context.monitors_in_flight = 0;
89 metrics_info_fini (&ctx->metrics_info);
93 context_get_current (void)
95 return ¤t_context;