]> git.sesse.net Git - movit/blob - init.h
Use std::scientific when outputting floats, so we do not get issues with 0.0 being...
[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 // This is a temporary hack until we add something more solid.
21 //
22 // The second parameter specifies whether debugging is on or off.
23 // If it is on, Movit will write intermediate graphs and the final
24 // generated shaders to the current directory.
25 //
26 // If you call init_movit() twice with different parameters,
27 // only the first will count, and the second will always return true.
28 bool init_movit(const std::string& data_directory, MovitDebugLevel debug_level) MUST_CHECK_RESULT;
29
30 // GPU features. These are not intended for end-user use.
31
32 // Whether init_movit() has been called.
33 extern bool movit_initialized;
34
35 // The current debug level.
36 extern MovitDebugLevel movit_debug_level;
37
38 // An estimate on the smallest values the linear texture interpolation
39 // of the GPU can distinguish between, i.e., for a GPU with N-bit
40 // texture subpixel precision, this value will be 2^-N.
41 //
42 // From reading the little specs that exist and through practical tests,
43 // the broad picture seems to be that Intel cards have 6-bit precision,
44 // nVidia cards have 8-bit, and Radeon cards have 6-bit before R6xx
45 // (at least when not using trilinear sampling), but can reach
46 // 8-bit precision on R6xx or newer in some (unspecified) cases.
47 //
48 // We currently don't bother to test for more than 1024 levels.
49 extern float movit_texel_subpixel_precision;
50
51 // Some GPUs use very inaccurate fixed-function circuits for rounding
52 // floating-point values to 8-bit outputs, leading to absurdities like
53 // the roundoff point between 128 and 129 being 128.62 instead of 128.6.
54 // We test, for every integer, x+0.48 and x+0.52 and check that they
55 // round the right way (giving some leeway, but not a lot); the number
56 // of errors are stored here.
57 //
58 // If this value is above 0, the extension GL_EXT_gpu_shader4 is available
59 // (giving round()) and you have enabled dithering, we will round off
60 // explicitly at the very end of the shader.
61 //
62 // Note: I don't know of any cards that round off wrong (well, outside
63 // our tolerance) and do not have this extension.
64 extern int movit_num_wrongly_rounded;
65 extern bool movit_shader_rounding_supported;
66
67 // Whether the GPU in use supports GL_EXT_texture_sRGB.
68 extern bool movit_srgb_textures_supported;
69
70 // What shader model we are compiling for. This only affects the choice
71 // of a few files (like header.frag); most of the shaders are the same.
72 enum MovitShaderModel {
73         MOVIT_GLSL_110,
74         MOVIT_GLSL_130,
75         MOVIT_ESSL_300
76 };
77 extern MovitShaderModel movit_shader_model;
78
79 }  // namespace movit
80
81 #endif  // !defined(_MOVIT_INIT_H)