]> git.cworth.org Git - fips/blob - metrics.h
Collect any available results before switching contexts.
[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 typedef enum
26 {
27         METRICS_OP_ACCUM,
28         METRICS_OP_BUFFER_DATA,
29         METRICS_OP_BUFFER_SUB_DATA,
30         METRICS_OP_BITMAP,
31         METRICS_OP_BLIT_FRAMEBUFFER,
32         METRICS_OP_CLEAR,
33         METRICS_OP_CLEAR_BUFFER_DATA,
34         METRICS_OP_CLEAR_TEX_IMAGE,
35         METRICS_OP_COPY_PIXELS,
36         METRICS_OP_COPY_TEX_IMAGE,
37         METRICS_OP_DRAW_PIXELS,
38         METRICS_OP_GET_TEX_IMAGE,
39         METRICS_OP_READ_PIXELS,
40         METRICS_OP_TEX_IMAGE,
41
42         /* METRICS_OP_SHADER must be last.
43          * 
44          * All larger values for metrics_op_t are interpreted as:
45          *
46          *      METRICS_OP_SHADER + shader_program_number
47          *
48          * to indicate a specific shader program.
49          */
50         METRICS_OP_SHADER
51 } metrics_op_t;
52
53 /* Initialize metrics info
54  *
55  * This queries the names and ranges for all available performance counters.
56  *
57  * This should be called once before any other metrics functions.
58  */
59 void
60 metrics_info_init (void);
61
62 /* Finalize metrics info state.
63  *
64  * The function should be called just before setting a new, current,
65  * OpenGL context.
66  */
67 void
68 metrics_info_fini (void);
69
70 /* Start accumulating GPU time.
71  *
72  * The time accumulated will be accounted against the
73  * current program (as set with metrics_set_current_program).
74  */
75 void
76 metrics_counter_start (void);
77
78 /* Stop accumulating GPU time (stops the most-recently started counter) */
79 void
80 metrics_counter_stop (void);
81
82 /* Set a metrics_op_t value to indicate what kind of operation is
83  * being performed.
84  *
85  * The metrics-tracking code will account for timings by accumulating
86  * measured counter values into a separate counter for each
87  * metrics_op_t value, (so that the report can describe which
88  * operations are the most expensive).
89  *
90  * In addition, for the value METRICS_OP_SHADER, each specific shader
91  * program can be distinguished. To accomplish this, pass a value of
92  * METRICS_OP_SHADER + shader_program_number to this function.
93  */
94 void
95 metrics_set_current_op (metrics_op_t op);
96
97 /* Return the current metrics_op_t value, (the value most-recently-set
98  * with a call to metrics_set_current_op).
99  */
100 metrics_op_t
101 metrics_get_current_op (void);
102
103 /* Should be called at the end of every function wrapper for a
104  * function that ends a frame, (glXSwapBuffers and similar).
105  *
106  * This function performs whatever bookkeeping is necessary to
107  * generate a timing report, then emits that report.
108  */
109 void
110 metrics_end_frame (void);
111
112 #endif