]> git.sesse.net Git - movit/blob - init.h
Compile shaders into the library.
[movit] / init.h
1 #ifndef _MOVIT_INIT_H
2 #define _MOVIT_INIT_H
3
4 #include "defs.h"
5 #include <string>
6
7 namespace movit {
8
9 enum MovitDebugLevel {
10         MOVIT_DEBUG_OFF = 0,
11         MOVIT_DEBUG_ON = 1,
12 };
13
14 // Initialize the library; in particular, will query the GPU for information
15 // that is needed by various components. For instance, it verifies that
16 // we have all the OpenGL extensions we need. Returns true if initialization
17 // succeeded.
18 //
19 // The first parameter gives which directory to read .frag files from.
20 // If you use "", or the file isn't found, a compiled-in version will
21 // be used instead (if it exists). Most users should probably use ""
22 // unless you need backwards compatibility with Movit 1.6.3 or older.
23 //
24 // The second parameter specifies whether debugging is on or off.
25 // If it is on, Movit will write intermediate graphs and the final
26 // generated shaders to the current directory.
27 //
28 // If you call init_movit() twice with different parameters,
29 // only the first will count, and the second will always return true.
30 bool init_movit(const std::string& data_directory, MovitDebugLevel debug_level) MUST_CHECK_RESULT;
31
32 // GPU features. These are not intended for end-user use.
33
34 // Whether init_movit() has been called.
35 extern bool movit_initialized;
36
37 // The current debug level.
38 extern MovitDebugLevel movit_debug_level;
39
40 // An estimate on the smallest values the linear texture interpolation
41 // of the GPU can distinguish between, i.e., for a GPU with N-bit
42 // texture subpixel precision, this value will be 2^-N.
43 //
44 // From reading the little specs that exist and through practical tests,
45 // the broad picture seems to be that Intel cards have 6-bit precision,
46 // nVidia cards have 8-bit, and Radeon cards have 6-bit before R6xx
47 // (at least when not using trilinear sampling), but can reach
48 // 8-bit precision on R6xx or newer in some (unspecified) cases.
49 //
50 // We currently don't bother to test for more than 1024 levels.
51 extern float movit_texel_subpixel_precision;
52
53 // Some GPUs use very inaccurate fixed-function circuits for rounding
54 // floating-point values to 8-bit outputs, leading to absurdities like
55 // the roundoff point between 128 and 129 being 128.62 instead of 128.5.
56 // We test, for every integer, x+0.48 and x+0.52 and check that they
57 // round the right way (giving some leeway, but not a lot); the number
58 // of errors are stored here.
59 //
60 // If this value is above 0, we will round off explicitly at the very end
61 // of the shader. Note the following limitations:
62 //
63 //   - The measurement is done on linear 8-bit, not any sRGB format,
64 //     10-bit output, or the likes.
65 //   - This only covers the final pass; intermediates are not covered
66 //     (only relevant if you use e.g. GL_SRGB8 intermediates).
67 extern int movit_num_wrongly_rounded;
68
69 // Whether the OpenGL driver (or GPU) in use supports GL_ARB_timer_query.
70 extern bool movit_timer_queries_supported;
71
72 // Whether the OpenGL driver (or GPU) in use supports compute shaders.
73 // Note that certain OpenGL implementations might only allow this in core mode.
74 extern bool movit_compute_shaders_supported;
75
76 // What shader model we are compiling for. This only affects the choice
77 // of a few files (like header.frag); most of the shaders are the same.
78 enum MovitShaderModel {
79         MOVIT_GLSL_110,  // No longer in use, but kept until next ABI break in order not to change the enums.
80         MOVIT_GLSL_130,
81         MOVIT_ESSL_300,
82         MOVIT_GLSL_150,
83 };
84 extern MovitShaderModel movit_shader_model;
85
86 }  // namespace movit
87
88 #endif  // !defined(_MOVIT_INIT_H)