]> git.sesse.net Git - movit/blob - init.h
25869d17b1d266e5440bfedaeda8a79e0633ec4d
[movit] / init.h
1 #ifndef _MOVIT_INIT_H
2 #define _MOVIT_INIT_H
3
4 #include "defs.h"
5 #include <string>
6
7 enum MovitDebugLevel {
8         MOVIT_DEBUG_OFF = 0,
9         MOVIT_DEBUG_ON = 1,
10 };
11
12 // Initialize the library; in particular, will query the GPU for information
13 // that is needed by various components. For instance, it verifies that
14 // we have all the OpenGL extensions we need. Returns true if initialization
15 // succeeded.
16 //
17 // The first parameter gives which directory to read .frag files from.
18 // This is a temporary hack until we add something more solid.
19 //
20 // The second parameter specifies whether debugging is on or off.
21 // If it is on, Movit will write intermediate graphs and the final
22 // generated shaders to the current directory.
23 //
24 // If you call init_movit() twice with different parameters,
25 // only the first will count, and the second will always return true.
26 bool init_movit(const std::string& data_directory, MovitDebugLevel debug_level) MUST_CHECK_RESULT;
27
28 // GPU features. These are not intended for end-user use.
29
30 // Whether init_movit() has been called.
31 extern bool movit_initialized;
32
33 // The current debug level.
34 extern MovitDebugLevel movit_debug_level;
35
36 // An estimate on the smallest values the linear texture interpolation
37 // of the GPU can distinguish between, i.e., for a GPU with N-bit
38 // texture subpixel precision, this value will be 2^-N.
39 //
40 // From reading the little specs that exist and through practical tests,
41 // the broad picture seems to be that Intel cards have 6-bit precision,
42 // nVidia cards have 8-bit, and Radeon cards have 6-bit before R6xx
43 // (at least when not using trilinear sampling), but can reach
44 // 8-bit precision on R6xx or newer in some (unspecified) cases.
45 //
46 // We currently don't bother to test for more than 1024 levels.
47 extern float movit_texel_subpixel_precision;
48
49 // Some GPUs use very inaccurate fixed-function circuits for rounding
50 // floating-point values to 8-bit outputs, leading to absurdities like
51 // the roundoff point between 128 and 129 being 128.62 instead of 128.6.
52 // We test, for every integer, x+0.48 and x+0.52 and check that they
53 // round the right way (giving some leeway, but not a lot); the number
54 // of errors are stored here.
55 //
56 // If this value is above 0, the extension GL_EXT_gpu_shader4 is available
57 // (giving round()) and you have enabled dithering, we will round off
58 // explicitly at the very end of the shader.
59 //
60 // Note: I don't know of any cards that round off wrong (well, outside
61 // our tolerance) and do not have this extension.
62 extern int movit_num_wrongly_rounded;
63 extern bool movit_shader_rounding_supported;
64
65 // Whether the GPU in use supports GL_EXT_texture_sRGB.
66 extern bool movit_srgb_textures_supported;
67
68 #endif  // !defined(_MOVIT_INIT_H)