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
25 #include "metrics-info.h"
30 METRICS_OP_BUFFER_DATA,
31 METRICS_OP_BUFFER_SUB_DATA,
33 METRICS_OP_BLIT_FRAMEBUFFER,
35 METRICS_OP_CLEAR_BUFFER_DATA,
36 METRICS_OP_CLEAR_TEX_IMAGE,
37 METRICS_OP_COPY_PIXELS,
38 METRICS_OP_COPY_TEX_IMAGE,
39 METRICS_OP_DRAW_PIXELS,
40 METRICS_OP_GET_TEX_IMAGE,
41 METRICS_OP_READ_PIXELS,
44 /* METRICS_OP_SHADER must be last.
46 * All larger values for metrics_op_t are interpreted as:
48 * METRICS_OP_SHADER + shader_program_number
50 * to indicate a specific shader program.
55 typedef struct metrics metrics_t;
57 /* Create a new metrics_t object for tracking metrics, given the
58 * pre-initialized metrics_info_t* describing available counters. */
60 metrics_create (metrics_info_t *info);
62 /* Free all internal resources of a metrics_t
64 * All outstanding metrics counters are discarded.
66 * The metrics_t object remains valid and may be used again.
69 metrics_fini (metrics_t *metrics);
71 /* Destroy a metrics_t object.
73 * After this call, the metrics_t* value is and must not be used
76 metrics_destroy (metrics_t *metrics);
78 /* Start accumulating GPU time.
80 * The time accumulated will be accounted against the
81 * current program (as set with metrics_set_current_program).
84 metrics_counter_start (metrics_t *metrics);
86 /* Stop accumulating GPU time (stops the most-recently started counter) */
88 metrics_counter_stop (metrics_t *metrics);
90 /* Set a metrics_op_t value to indicate what kind of operation is
93 * The metrics-tracking code will account for timings by accumulating
94 * measured counter values into a separate counter for each
95 * metrics_op_t value, (so that the report can describe which
96 * operations are the most expensive).
98 * In addition, for the value METRICS_OP_SHADER, each specific shader
99 * program can be distinguished. To accomplish this, pass a value of
100 * METRICS_OP_SHADER + shader_program_number to this function.
103 metrics_set_current_op (metrics_t *metrics, metrics_op_t op);
105 /* Return the current metrics_op_t value, (the value most-recently-set
106 * with a call to metrics_set_current_op).
109 metrics_get_current_op (metrics_t *metrics);
111 /* This pair of functions can be used to indicate a frame end.
113 * Both functions should be by every function wrapper for a function
114 * that ends a frame, (glXSwapBuffers and similar). The pre_swap
115 * before the call to the underlying swap function, and post_swap
118 * These functions trigger whatever bookkeeping is necessary to
119 * generate a timing report, (such as collecting any outstanding timer
120 * query values), and will also emit those reports when necessary.
123 metrics_end_frame_pre_swap (metrics_t *metrics);
126 metrics_end_frame_post_swap (metrics_t *metrics);
128 /* Process outstanding metrics requests, accumulating results.
130 * This function is called automatically by metrics_end_frame.
132 * During a frame, it may be important to call this function to avoid
133 * too many oustanding timer/performance-monitor queries. At the same
134 * time, it's important not to call this function too frequently,
135 * since collection of metrics information will result in flushes of
136 * the OpenGL pipeline which can interfere with the behavior being
140 metrics_collect_available (metrics_t *metrics);