1 /*
2  * Copyright © 2019 Intel Corporation
3  *
4  * Permission is hereby granted, free of charge, to any person obtaining a
5  * copy of this software and associated documentation files (the "Software"),
6  * to deal in the Software without restriction, including without limitation
7  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
8  * and/or sell copies of the Software, and to permit persons to whom the
9  * Software is furnished to do so, subject to the following conditions:
10  *
11  * The above copyright notice and this permission notice (including the next
12  * paragraph) shall be included in all copies or substantial portions of the
13  * Software.
14  *
15  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
18  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
20  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
21  * IN THE SOFTWARE.
22  */
23 
24 #ifndef OVERLAY_PARAMS_H
25 #define OVERLAY_PARAMS_H
26 
27 #ifdef __cplusplus
28 extern "C" {
29 #endif
30 
31 #include <stdio.h>
32 #include <stdint.h>
33 #include <stdbool.h>
34 
35 #define OVERLAY_PARAMS                               \
36    OVERLAY_PARAM_BOOL(fps)                           \
37    OVERLAY_PARAM_BOOL(frame)                         \
38    OVERLAY_PARAM_BOOL(frame_timing)                  \
39    OVERLAY_PARAM_BOOL(submit)                        \
40    OVERLAY_PARAM_BOOL(draw)                          \
41    OVERLAY_PARAM_BOOL(draw_indexed)                  \
42    OVERLAY_PARAM_BOOL(draw_indirect)                 \
43    OVERLAY_PARAM_BOOL(draw_indexed_indirect)         \
44    OVERLAY_PARAM_BOOL(draw_indirect_count)           \
45    OVERLAY_PARAM_BOOL(draw_indexed_indirect_count)   \
46    OVERLAY_PARAM_BOOL(dispatch)                      \
47    OVERLAY_PARAM_BOOL(dispatch_indirect)             \
48    OVERLAY_PARAM_BOOL(pipeline_graphics)             \
49    OVERLAY_PARAM_BOOL(pipeline_compute)              \
50    OVERLAY_PARAM_BOOL(pipeline_raytracing)           \
51    OVERLAY_PARAM_BOOL(acquire)                       \
52    OVERLAY_PARAM_BOOL(acquire_timing)                \
53    OVERLAY_PARAM_BOOL(present_timing)                \
54    OVERLAY_PARAM_BOOL(vertices)                      \
55    OVERLAY_PARAM_BOOL(primitives)                    \
56    OVERLAY_PARAM_BOOL(vert_invocations)              \
57    OVERLAY_PARAM_BOOL(geom_invocations)              \
58    OVERLAY_PARAM_BOOL(geom_primitives)               \
59    OVERLAY_PARAM_BOOL(clip_invocations)              \
60    OVERLAY_PARAM_BOOL(clip_primitives)               \
61    OVERLAY_PARAM_BOOL(frag_invocations)              \
62    OVERLAY_PARAM_BOOL(tess_ctrl_patches)             \
63    OVERLAY_PARAM_BOOL(tess_eval_invocations)         \
64    OVERLAY_PARAM_BOOL(compute_invocations)           \
65    OVERLAY_PARAM_BOOL(gpu_timing)                    \
66    OVERLAY_PARAM_CUSTOM(fps_sampling_period)         \
67    OVERLAY_PARAM_CUSTOM(output_file)                 \
68    OVERLAY_PARAM_CUSTOM(position)                    \
69    OVERLAY_PARAM_CUSTOM(width)                       \
70    OVERLAY_PARAM_CUSTOM(height)                      \
71    OVERLAY_PARAM_CUSTOM(no_display)                  \
72    OVERLAY_PARAM_CUSTOM(control)                     \
73    OVERLAY_PARAM_CUSTOM(help)
74 
75 enum overlay_param_position {
76    LAYER_POSITION_TOP_LEFT,
77    LAYER_POSITION_TOP_RIGHT,
78    LAYER_POSITION_BOTTOM_LEFT,
79    LAYER_POSITION_BOTTOM_RIGHT,
80 };
81 
82 enum overlay_param_enabled {
83 #define OVERLAY_PARAM_BOOL(name) OVERLAY_PARAM_ENABLED_##name,
84 #define OVERLAY_PARAM_CUSTOM(name)
85    OVERLAY_PARAMS
86 #undef OVERLAY_PARAM_BOOL
87 #undef OVERLAY_PARAM_CUSTOM
88    OVERLAY_PARAM_ENABLED_MAX
89 };
90 
91 struct overlay_params {
92    bool enabled[OVERLAY_PARAM_ENABLED_MAX];
93    enum overlay_param_position position;
94    FILE *output_file;
95    int control;
96    uint32_t fps_sampling_period; /* us */
97    bool help;
98    bool no_display;
99    unsigned width;
100    unsigned height;
101 };
102 
103 const extern char *overlay_param_names[];
104 
105 void parse_overlay_env(struct overlay_params *params,
106                        const char *env);
107 
108 #ifdef __cplusplus
109 }
110 #endif
111 
112 #endif /* OVERLAY_PARAMS_H */
113