]> git.cworth.org Git - fips/blob - metrics.h
Add explicit link to libpthread, to work around debugging issues
[fips] / metrics.h
1 /* Copyright © 2013, Intel Corporation
2  *
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:
9  *
10  * The above copyright notice and this permission notice shall be included in
11  * all copies or substantial portions of the Software.
12  *
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
19  * THE SOFTWARE.
20  */
21
22 #ifndef METRICS_H
23 #define METRICS_H
24
25 #include "metrics-info.h"
26
27 typedef enum
28 {
29         METRICS_OP_ACCUM,
30         METRICS_OP_BUFFER_DATA,
31         METRICS_OP_BUFFER_SUB_DATA,
32         METRICS_OP_BITMAP,
33         METRICS_OP_BLIT_FRAMEBUFFER,
34         METRICS_OP_CLEAR,
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,
42         METRICS_OP_TEX_IMAGE,
43
44         /* METRICS_OP_SHADER must be last.
45          * 
46          * All larger values for metrics_op_t are interpreted as:
47          *
48          *      METRICS_OP_SHADER + shader_program_number
49          *
50          * to indicate a specific shader program.
51          */
52         METRICS_OP_SHADER
53 } metrics_op_t;
54
55 typedef struct metrics metrics_t;
56
57 /* Create a new metrics_t object for tracking metrics, given the
58  * pre-initialized metrics_info_t* describing available counters. */
59 metrics_t *
60 metrics_create (metrics_info_t *info);
61
62 /* Free all internal resources of a metrics_t
63  *
64  * All outstanding metrics counters are discarded.
65  *
66  * The metrics_t object remains valid and may be used again.
67  */
68 void
69 metrics_fini (metrics_t *metrics);
70
71 /* Destroy a metrics_t object.
72  *
73  * After this call, the metrics_t* value is and must not be used
74  * further. */
75 void
76 metrics_destroy (metrics_t *metrics);
77
78 /* Start accumulating GPU time.
79  *
80  * The time accumulated will be accounted against the
81  * current program (as set with metrics_set_current_program).
82  */
83 void
84 metrics_counter_start (metrics_t *metrics);
85
86 /* Stop accumulating GPU time (stops the most-recently started counter) */
87 void
88 metrics_counter_stop (metrics_t *metrics);
89
90 /* Set a metrics_op_t value to indicate what kind of operation is
91  * being performed.
92  *
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).
97  *
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.
101  */
102 void
103 metrics_set_current_op (metrics_t *metrics, metrics_op_t op);
104
105 /* Return the current metrics_op_t value, (the value most-recently-set
106  * with a call to metrics_set_current_op).
107  */
108 metrics_op_t
109 metrics_get_current_op (metrics_t *metrics);
110
111 /* Should be called at the end of every function wrapper for a
112  * function that ends a frame, (glXSwapBuffers and similar).
113  *
114  * This function performs whatever bookkeeping is necessary to
115  * generate a timing report, then emits that report.
116  */
117 void
118 metrics_end_frame (metrics_t *metrics);
119
120 /* Process outstanding metrics requests, accumulating results.
121  *
122  * This function is called automatically by metrics_end_frame.
123  *
124  * During a frame, it may be important to call this function to avoid
125  * too many oustanding timer/performance-monitor queries. At the same
126  * time, it's important not to call this function too frequently,
127  * since collection of metrics information will result in flushes of
128  * the OpenGL pipeline which can interfere with the behavior being
129  * measured.
130  */
131 void
132 metrics_collect_available (metrics_t *metrics);
133
134 #endif