Merge commit 'origin/gallium-0.1' into gallium-0.2
[mesa.git] / src / mesa / drivers / dri / common / xmlconfig.h
1 /*
2 * XML DRI client-side driver configuration
3 * Copyright (C) 2003 Felix Kuehling
4 *
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
11 *
12 * The above copyright notice and this permission notice shall be included
13 * in all copies or substantial portions of the Software.
14 *
15 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18 * FELIX KUEHLING, OR ANY OTHER CONTRIBUTORS BE LIABLE FOR ANY CLAIM,
19 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
20 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE
21 * OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
22 *
23 */
24 /**
25 * \file xmlconfig.h
26 * \brief Driver-independent client-side part of the XML configuration
27 * \author Felix Kuehling
28 */
29
30 #ifndef __XMLCONFIG_H
31 #define __XMLCONFIG_H
32
33 /** \brief Option data types */
34 typedef enum driOptionType {
35 DRI_BOOL, DRI_ENUM, DRI_INT, DRI_FLOAT
36 } driOptionType;
37
38 /** \brief Option value */
39 typedef union driOptionValue {
40 GLboolean _bool; /**< \brief Boolean */
41 GLint _int; /**< \brief Integer or Enum */
42 GLfloat _float; /**< \brief Floating-point */
43 } driOptionValue;
44
45 /** \brief Single range of valid values
46 *
47 * For empty ranges (a single value) start == end */
48 typedef struct driOptionRange {
49 driOptionValue start; /**< \brief Start */
50 driOptionValue end; /**< \brief End */
51 } driOptionRange;
52
53 /** \brief Information about an option */
54 typedef struct driOptionInfo {
55 char *name; /**< \brief Name */
56 driOptionType type; /**< \brief Type */
57 driOptionRange *ranges; /**< \brief Array of ranges */
58 GLuint nRanges; /**< \brief Number of ranges */
59 } driOptionInfo;
60
61 /** \brief Option cache
62 *
63 * \li One in <driver>Screen caching option info and the default values
64 * \li One in each <driver>Context with the actual values for that context */
65 typedef struct driOptionCache {
66 driOptionInfo *info;
67 /**< \brief Array of option infos
68 *
69 * Points to the same array in the screen and all contexts */
70 driOptionValue *values;
71 /**< \brief Array of option values
72 *
73 * \li Default values in screen
74 * \li Actual values in contexts
75 */
76 GLuint tableSize;
77 /**< \brief Size of the arrays
78 *
79 * Depending on the hash function this may differ from __driNConfigOptions.
80 * In the current implementation it's not actually a size but log2(size).
81 * The value is the same in the screen and all contexts. */
82 } driOptionCache;
83
84 /** \brief Parse XML option info from configOptions
85 *
86 * To be called in <driver>CreateScreen
87 *
88 * \param info pointer to a driOptionCache that will store the option info
89 * \param configOptions XML document describing available configuration opts
90 * \param nConfigOptions number of options, used to choose a hash table size
91 *
92 * For the option information to be available to external configuration tools
93 * it must be a public symbol __driConfigOptions. It is also passed as a
94 * parameter to driParseOptionInfo in order to avoid driver-independent code
95 * depending on symbols in driver-specific code. */
96 void driParseOptionInfo (driOptionCache *info,
97 const char *configOptions, GLuint nConfigOptions);
98 /** \brief Initialize option cache from info and parse configuration files
99 *
100 * To be called in <driver>CreateContext. screenNum and driverName select
101 * device sections. */
102 void driParseConfigFiles (driOptionCache *cache, const driOptionCache *info,
103 GLint screenNum, const char *driverName);
104 /** \brief Destroy option info
105 *
106 * To be called in <driver>DestroyScreen */
107 void driDestroyOptionInfo (driOptionCache *info);
108 /** \brief Destroy option cache
109 *
110 * To be called in <driver>DestroyContext */
111 void driDestroyOptionCache (driOptionCache *cache);
112
113 /** \brief Check if there exists a certain option */
114 GLboolean driCheckOption (const driOptionCache *cache, const char *name,
115 driOptionType type);
116
117 /** \brief Query a boolean option value */
118 GLboolean driQueryOptionb (const driOptionCache *cache, const char *name);
119 /** \brief Query an integer option value */
120 GLint driQueryOptioni (const driOptionCache *cache, const char *name);
121 /** \brief Query a floating-point option value */
122 GLfloat driQueryOptionf (const driOptionCache *cache, const char *name);
123
124 #endif