move mesa32 over to new dir
[reactos.git] / reactos / lib / mesa32 / src / x86 / gen_matypes.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 5.1
4 *
5 * Copyright (C) 1999-2003 Brian Paul All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
23 *
24 * Authors:
25 * Gareth Hughes
26 */
27
28 /*
29 * This generates an asm version of mtypes.h (called matypes.h), so that
30 * Mesa's x86 assembly code can access the internal structures easily.
31 * This will be particularly useful when developing new x86 asm code for
32 * Mesa, including lighting, clipping, texture image conversion etc.
33 */
34
35 #include "main/glheader.h"
36 #include "main/mtypes.h"
37 #include "tnl/t_context.h"
38
39
40 #undef offsetof
41 #define offsetof( type, member ) ((size_t) &((type *)0)->member)
42
43
44 #define OFFSET_HEADER( x ) \
45 do { \
46 printf( "\n" ); \
47 printf( "\n" ); \
48 printf( "/* =====================================================" \
49 "========\n" ); \
50 printf( " * Offsets for %s\n", x ); \
51 printf( " */\n" ); \
52 printf( "\n" ); \
53 } while (0)
54
55 #define DEFINE_HEADER( x ) \
56 do { \
57 printf( "\n" ); \
58 printf( "/*\n" ); \
59 printf( " * Flags for %s\n", x ); \
60 printf( " */\n" ); \
61 printf( "\n" ); \
62 } while (0)
63
64 #if defined(__BEOS__) || defined(_LP64)
65 #define OFFSET( s, t, m ) \
66 printf( "#define %s\t%ld\n", s, offsetof( t, m ) );
67 #else
68 #define OFFSET( s, t, m ) \
69 printf( "#define %s\t%d\n", s, offsetof( t, m ) );
70 #endif
71
72 #if defined(__BEOS__) || defined(_LP64)
73 #define SIZEOF( s, t ) \
74 printf( "#define %s\t%ld\n", s, sizeof(t) );
75 #else
76 #define SIZEOF( s, t ) \
77 printf( "#define %s\t%d\n", s, sizeof(t) );
78 #endif
79
80 #define DEFINE( s, d ) \
81 printf( "#define %s\t0x%x\n", s, d );
82
83
84
85 int main( int argc, char **argv )
86 {
87 printf( "/*\n" );
88 printf( " * This file is automatically generated from the Mesa internal type\n" );
89 printf( " * definitions. Do not edit directly.\n" );
90 printf( " */\n" );
91 printf( "\n" );
92 printf( "#ifndef __ASM_TYPES_H__\n" );
93 printf( "#define __ASM_TYPES_H__\n" );
94 printf( "\n" );
95 printf( "#include \"assyntax.h\"\n" );
96
97
98 /* GLcontext offsets:
99 */
100 OFFSET_HEADER( "GLcontext" );
101
102 OFFSET( "CTX_DRIVER_CTX ", GLcontext, DriverCtx );
103 printf( "\n" );
104 OFFSET( "CTX_LIGHT_ENABLED ", GLcontext, Light.Enabled );
105 OFFSET( "CTX_LIGHT_SHADE_MODEL ", GLcontext, Light.ShadeModel );
106 OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", GLcontext, Light.ColorMaterialFace );
107 OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", GLcontext, Light.ColorMaterialMode );
108 OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", GLcontext, Light.ColorMaterialBitmask );
109 OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", GLcontext, Light.ColorMaterialEnabled );
110 OFFSET( "CTX_LIGHT_ENABLED_LIST ", GLcontext, Light.EnabledList );
111 OFFSET( "CTX_LIGHT_NEED_VERTS ", GLcontext, Light._NeedVertices );
112 OFFSET( "CTX_LIGHT_FLAGS ", GLcontext, Light._Flags );
113 OFFSET( "CTX_LIGHT_BASE_COLOR ", GLcontext, Light._BaseColor );
114
115
116 /* struct vertex_buffer offsets:
117 */
118 OFFSET_HEADER( "struct vertex_buffer" );
119
120 OFFSET( "VB_SIZE ", struct vertex_buffer, Size );
121 OFFSET( "VB_COUNT ", struct vertex_buffer, Count );
122 printf( "\n" );
123 OFFSET( "VB_ELTS ", struct vertex_buffer, Elts );
124 OFFSET( "VB_OBJ_PTR ", struct vertex_buffer, ObjPtr );
125 OFFSET( "VB_EYE_PTR ", struct vertex_buffer, EyePtr );
126 OFFSET( "VB_CLIP_PTR ", struct vertex_buffer, ClipPtr );
127 OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer, NdcPtr );
128 OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer, ClipOrMask );
129 OFFSET( "VB_CLIP_MASK ", struct vertex_buffer, ClipMask );
130 OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer, NormalPtr );
131 OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer, EdgeFlag );
132 OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer, TexCoordPtr[0] );
133 OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer, TexCoordPtr[1] );
134 OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer, TexCoordPtr[2] );
135 OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer, TexCoordPtr[3] );
136 OFFSET( "VB_INDEX_PTR ", struct vertex_buffer, IndexPtr );
137 OFFSET( "VB_COLOR_PTR ", struct vertex_buffer, ColorPtr );
138 OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer, SecondaryColorPtr );
139 OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer, FogCoordPtr );
140 OFFSET( "VB_POINT_SIZE_PTR ", struct vertex_buffer, PointSizePtr );
141 OFFSET( "VB_PRIMITIVE ", struct vertex_buffer, Primitive );
142 printf( "\n" );
143 OFFSET( "VB_LAST_CLIPPED ", struct vertex_buffer, LastClipped );
144
145 DEFINE_HEADER( "struct vertex_buffer" );
146
147 /* XXX use new labels here someday after vertex proram is done */
148 DEFINE( "VERT_BIT_OBJ ", VERT_BIT_POS );
149 DEFINE( "VERT_BIT_NORM ", VERT_BIT_NORMAL );
150 DEFINE( "VERT_BIT_RGBA ", VERT_BIT_COLOR0 );
151 DEFINE( "VERT_BIT_SPEC_RGB ", VERT_BIT_COLOR1 );
152 DEFINE( "VERT_BIT_FOG_COORD ", VERT_BIT_FOG );
153 DEFINE( "VERT_BIT_TEX0 ", VERT_BIT_TEX0 );
154 DEFINE( "VERT_BIT_TEX1 ", VERT_BIT_TEX1 );
155 DEFINE( "VERT_BIT_TEX2 ", VERT_BIT_TEX2 );
156 DEFINE( "VERT_BIT_TEX3 ", VERT_BIT_TEX3 );
157
158
159 /* GLvector4f offsets:
160 */
161 OFFSET_HEADER( "GLvector4f" );
162
163 OFFSET( "V4F_DATA ", GLvector4f, data );
164 OFFSET( "V4F_START ", GLvector4f, start );
165 OFFSET( "V4F_COUNT ", GLvector4f, count );
166 OFFSET( "V4F_STRIDE ", GLvector4f, stride );
167 OFFSET( "V4F_SIZE ", GLvector4f, size );
168 OFFSET( "V4F_FLAGS ", GLvector4f, flags );
169
170 DEFINE_HEADER( "GLvector4f" );
171
172 DEFINE( "VEC_MALLOC ", VEC_MALLOC );
173 DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE );
174 DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE );
175 printf( "\n" );
176 DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1 );
177 DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2 );
178 DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3 );
179 DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4 );
180
181
182 /* GLmatrix offsets:
183 */
184 OFFSET_HEADER( "GLmatrix" );
185
186 OFFSET( "MATRIX_DATA ", GLmatrix, m );
187 OFFSET( "MATRIX_INV ", GLmatrix, inv );
188 OFFSET( "MATRIX_FLAGS ", GLmatrix, flags );
189 OFFSET( "MATRIX_TYPE ", GLmatrix, type );
190
191
192 /* struct gl_light offsets:
193 */
194 OFFSET_HEADER( "struct gl_light" );
195
196 OFFSET( "LIGHT_NEXT ", struct gl_light, next );
197 OFFSET( "LIGHT_PREV ", struct gl_light, prev );
198 printf( "\n" );
199 OFFSET( "LIGHT_AMBIENT ", struct gl_light, Ambient );
200 OFFSET( "LIGHT_DIFFUSE ", struct gl_light, Diffuse );
201 OFFSET( "LIGHT_SPECULAR ", struct gl_light, Specular );
202 OFFSET( "LIGHT_EYE_POSITION ", struct gl_light, EyePosition );
203 OFFSET( "LIGHT_EYE_DIRECTION ", struct gl_light, EyeDirection );
204 OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light, SpotExponent );
205 OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light, SpotCutoff );
206 OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light, _CosCutoff );
207 OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light, ConstantAttenuation );
208 OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light, LinearAttenuation );
209 OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light, QuadraticAttenuation );
210 OFFSET( "LIGHT_ENABLED ", struct gl_light, Enabled );
211 printf( "\n" );
212 OFFSET( "LIGHT_FLAGS ", struct gl_light, _Flags );
213 printf( "\n" );
214 OFFSET( "LIGHT_POSITION ", struct gl_light, _Position );
215 OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light, _VP_inf_norm );
216 OFFSET( "LIGHT_H_INF_NORM ", struct gl_light, _h_inf_norm );
217 OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light, _NormDirection );
218 OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light, _VP_inf_spot_attenuation );
219 printf( "\n" );
220 OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light, _SpotExpTable );
221 OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light, _MatAmbient );
222 OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light, _MatDiffuse );
223 OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light, _MatSpecular );
224 printf( "\n" );
225 SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light );
226
227 DEFINE_HEADER( "struct gl_light" );
228
229 DEFINE( "LIGHT_SPOT ", LIGHT_SPOT );
230 DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER );
231 DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL );
232 printf( "\n" );
233 DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES );
234
235
236 /* struct gl_lightmodel offsets:
237 */
238 OFFSET_HEADER( "struct gl_lightmodel" );
239
240 OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel, Ambient );
241 OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel, LocalViewer );
242 OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel, TwoSide );
243 OFFSET( "LIGHT_MODEL_COLOR_CONTROL ", struct gl_lightmodel, ColorControl );
244
245
246 printf( "\n" );
247 printf( "\n" );
248 printf( "#endif /* __ASM_TYPES_H__ */\n" );
249
250 return 0;
251 }