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