simplify test for specific texture formats
[mesa.git] / src / mesa / x86 / gen_matypes.c
1 /* $Id: gen_matypes.c,v 1.1 2001/03/28 20:44:44 gareth 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 "context.h"
42 #include "mtypes.h"
43 #include "tnl/t_context.h"
44 #endif
45
46 #undef offsetof
47 #define offsetof( type, member ) ((size_t) &((type *)0)->member)
48
49
50 #define OFFSET_HEADER( x ) \
51 do { \
52 printf( "\n" ); \
53 printf( "\n" ); \
54 printf( "/* =====================================================" \
55 "========\n" ); \
56 printf( " * Offsets for %s\n", x ); \
57 printf( " */\n" ); \
58 printf( "\n" ); \
59 } while (0)
60
61 #define DEFINE_HEADER( x ) \
62 do { \
63 printf( "\n" ); \
64 printf( "/*\n" ); \
65 printf( " * Flags for %s\n", x ); \
66 printf( " */\n" ); \
67 printf( "\n" ); \
68 } while (0)
69
70 #define OFFSET( s, t, m ) \
71 printf( "#define %s\t%d\n", s, offsetof( t, m ) );
72
73 #define SIZEOF( s, t ) \
74 printf( "#define %s\t%d\n", s, sizeof(t) );
75
76 #define DEFINE( s, d ) \
77 printf( "#define %s\t0x%x\n", s, d );
78
79
80
81 int main( int argc, char **argv )
82 {
83 printf( "/*\n" );
84 printf( " * This file is automatically generated from the Mesa internal type\n" );
85 printf( " * definitions. Do not edit directly.\n" );
86 printf( " */\n" );
87 printf( "\n" );
88 printf( "#ifndef __ASM_TYPES_H__\n" );
89 printf( "#define __ASM_TYPES_H__\n" );
90 printf( "\n" );
91 printf( "#include \"assyntax.h\"\n" );
92
93
94 /* GLcontext offsets:
95 */
96 OFFSET_HEADER( "GLcontext" );
97
98 OFFSET( "CTX_DRIVER_CTX ", GLcontext, DriverCtx );
99 printf( "\n" );
100 OFFSET( "CTX_LIGHT_ENABLED ", GLcontext, Light.Enabled );
101 OFFSET( "CTX_LIGHT_SHADE_MODEL ", GLcontext, Light.ShadeModel );
102 OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", GLcontext, Light.ColorMaterialFace );
103 OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", GLcontext, Light.ColorMaterialMode );
104 OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", GLcontext, Light.ColorMaterialBitmask );
105 OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", GLcontext, Light.ColorMaterialEnabled );
106 OFFSET( "CTX_LIGHT_ENABLED_LIST ", GLcontext, Light.EnabledList );
107 OFFSET( "CTX_LIGHT_NEED_VERTS ", GLcontext, Light._NeedVertices );
108 OFFSET( "CTX_LIGHT_FLAGS ", GLcontext, Light._Flags );
109 OFFSET( "CTX_LIGHT_BASE_COLOR ", GLcontext, Light._BaseColor );
110 OFFSET( "CTX_LIGHT_BASE_ALPHA ", GLcontext, Light._BaseAlpha );
111
112
113 /* struct vertex_buffer offsets:
114 */
115 OFFSET_HEADER( "struct vertex_buffer" );
116
117 OFFSET( "VB_SIZE ", struct vertex_buffer, Size );
118 OFFSET( "VB_COUNT ", struct vertex_buffer, Count );
119 printf( "\n" );
120 OFFSET( "VB_FIRST_CLIPPED ", struct vertex_buffer, FirstClipped );
121 OFFSET( "VB_FIRST_PRIMITIVE ", struct vertex_buffer, FirstPrimitive );
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, ProjectedClipPtr );
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_MATERIAL ", struct vertex_buffer, Material );
142 OFFSET( "VB_MATERIAL_MASK ", struct vertex_buffer, MaterialMask );
143 OFFSET( "VB_FLAG ", struct vertex_buffer, Flag );
144 OFFSET( "VB_PRIMITIVE ", struct vertex_buffer, Primitive );
145 OFFSET( "VB_PRIMITIVE_LENGTH ", struct vertex_buffer, PrimitiveLength );
146 printf( "\n" );
147 OFFSET( "VB_IMPORTABLE_DATA ", struct vertex_buffer, importable_data );
148 printf( "\n" );
149 OFFSET( "VB_LAST_CLIPPED ", struct vertex_buffer, LastClipped );
150
151 DEFINE_HEADER( "struct vertex_buffer" );
152
153 DEFINE( "VERT_OBJ ", VERT_OBJ );
154 DEFINE( "VERT_RGBA ", VERT_RGBA );
155 DEFINE( "VERT_NORM ", VERT_NORM );
156 DEFINE( "VERT_INDEX ", VERT_INDEX );
157 DEFINE( "VERT_EDGE ", VERT_EDGE );
158 DEFINE( "VERT_SPEC_RGB ", VERT_SPEC_RGB );
159 DEFINE( "VERT_FOG_COORD ", VERT_FOG_COORD );
160 DEFINE( "VERT_TEX0 ", VERT_TEX0 );
161 DEFINE( "VERT_TEX1 ", VERT_TEX1 );
162 DEFINE( "VERT_TEX2 ", VERT_TEX2 );
163 DEFINE( "VERT_TEX3 ", VERT_TEX3 );
164 DEFINE( "VERT_EVAL_C1 ", VERT_EVAL_C1 );
165 DEFINE( "VERT_EVAL_C2 ", VERT_EVAL_C2 );
166 DEFINE( "VERT_EVAL_P1 ", VERT_EVAL_P1 );
167 DEFINE( "VERT_EVAL_P2 ", VERT_EVAL_P2 );
168 DEFINE( "VERT_OBJ_3 ", VERT_OBJ_3 );
169 DEFINE( "VERT_OBJ_4 ", VERT_OBJ_4 );
170 DEFINE( "VERT_MATERIAL ", VERT_MATERIAL );
171 DEFINE( "VERT_ELT ", VERT_ELT );
172 DEFINE( "VERT_BEGIN ", VERT_BEGIN );
173 DEFINE( "VERT_END ", VERT_END );
174 DEFINE( "VERT_END_VB ", VERT_END_VB );
175 DEFINE( "VERT_POINT_SIZE ", VERT_POINT_SIZE );
176 DEFINE( "VERT_EYE ", VERT_EYE );
177 DEFINE( "VERT_CLIP ", VERT_CLIP );
178 printf( "\n" );
179 DEFINE( "VERT_OBJ_23 ", VERT_OBJ_3 );
180 DEFINE( "VERT_OBJ_234 ", VERT_OBJ_4 );
181
182
183 /* GLvector3f offsets:
184 */
185 OFFSET_HEADER( "GLvector3f" );
186
187 OFFSET( "V3F_DATA ", GLvector3f, data );
188 OFFSET( "V3F_START ", GLvector3f, start );
189 OFFSET( "V3F_COUNT ", GLvector3f, count );
190 OFFSET( "V3F_STRIDE ", GLvector3f, stride );
191 OFFSET( "V3F_FLAGS ", GLvector3f, flags );
192
193
194 /* GLvector4f offsets:
195 */
196 OFFSET_HEADER( "GLvector4f" );
197
198 OFFSET( "V4F_DATA ", GLvector4f, data );
199 OFFSET( "V4F_START ", GLvector4f, start );
200 OFFSET( "V4F_COUNT ", GLvector4f, count );
201 OFFSET( "V4F_STRIDE ", GLvector4f, stride );
202 OFFSET( "V4F_SIZE ", GLvector4f, size );
203 OFFSET( "V4F_FLAGS ", GLvector4f, flags );
204
205 DEFINE_HEADER( "GLvector4f" );
206
207 DEFINE( "VEC_MALLOC ", VEC_MALLOC );
208 DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE );
209 DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE );
210 printf( "\n" );
211 DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1 );
212 DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2 );
213 DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3 );
214 DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4 );
215
216
217 /* GLmatrix offsets:
218 */
219 OFFSET_HEADER( "GLmatrix" );
220
221 OFFSET( "MATRIX_DATA ", GLmatrix, m );
222 OFFSET( "MATRIX_INV ", GLmatrix, inv );
223 OFFSET( "MATRIX_FLAGS ", GLmatrix, flags );
224 OFFSET( "MATRIX_TYPE ", GLmatrix, type );
225
226
227 /* struct gl_light offsets:
228 */
229 OFFSET_HEADER( "struct gl_light" );
230
231 OFFSET( "LIGHT_NEXT ", struct gl_light, next );
232 OFFSET( "LIGHT_PREV ", struct gl_light, prev );
233 printf( "\n" );
234 OFFSET( "LIGHT_AMBIENT ", struct gl_light, Ambient );
235 OFFSET( "LIGHT_DIFFUSE ", struct gl_light, Diffuse );
236 OFFSET( "LIGHT_SPECULAR ", struct gl_light, Specular );
237 OFFSET( "LIGHT_EYE_POSITION ", struct gl_light, EyePosition );
238 OFFSET( "LIGHT_EYE_DIRECTION ", struct gl_light, EyeDirection );
239 OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light, SpotExponent );
240 OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light, SpotCutoff );
241 OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light, _CosCutoff );
242 OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light, ConstantAttenuation );
243 OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light, LinearAttenuation );
244 OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light, QuadraticAttenuation );
245 OFFSET( "LIGHT_ENABLED ", struct gl_light, Enabled );
246 printf( "\n" );
247 OFFSET( "LIGHT_FLAGS ", struct gl_light, _Flags );
248 printf( "\n" );
249 OFFSET( "LIGHT_POSITION ", struct gl_light, _Position );
250 OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light, _VP_inf_norm );
251 OFFSET( "LIGHT_H_INF_NORM ", struct gl_light, _h_inf_norm );
252 OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light, _NormDirection );
253 OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light, _VP_inf_spot_attenuation );
254 printf( "\n" );
255 OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light, _SpotExpTable );
256 OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light, _MatAmbient );
257 OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light, _MatDiffuse );
258 OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light, _MatSpecular );
259 printf( "\n" );
260 SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light );
261
262 DEFINE_HEADER( "struct gl_light" );
263
264 DEFINE( "LIGHT_SPOT ", LIGHT_SPOT );
265 DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER );
266 DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL );
267 printf( "\n" );
268 DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES );
269
270
271 /* struct gl_lightmodel offsets:
272 */
273 OFFSET_HEADER( "struct gl_lightmodel" );
274
275 OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel, Ambient );
276 OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel, LocalViewer );
277 OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel, TwoSide );
278 OFFSET( "LIGHT_MODEL_COLOR_CONTROL ", struct gl_lightmodel, ColorControl );
279
280
281 printf( "\n" );
282 printf( "\n" );
283 printf( "#endif /* __ASM_TYPES_H__ */\n" );
284
285 return 0;
286 }