f2403c8c02ef4b28f3a8838029ae21ea36e0061d
1 /* $Id: gen_matypes.c,v 1.3 2001/07/28 19:28:49 keithw Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
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:
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
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.
27 * Gareth Hughes <gareth@valinux.com>
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.
42 #include "tnl/t_context.h"
46 #define offsetof( type, member ) ((size_t) &((type *)0)->member)
49 #define OFFSET_HEADER( x ) \
53 printf( "/* =====================================================" \
55 printf( " * Offsets for %s\n", x ); \
60 #define DEFINE_HEADER( x ) \
64 printf( " * Flags for %s\n", x ); \
69 #define OFFSET( s, t, m ) \
70 printf( "#define %s\t%d\n", s, offsetof( t, m ) );
72 #define SIZEOF( s, t ) \
73 printf( "#define %s\t%d\n", s, sizeof(t) );
75 #define DEFINE( s, d ) \
76 printf( "#define %s\t0x%x\n", s, d );
80 int main( int argc
, char **argv
)
83 printf( " * This file is automatically generated from the Mesa internal type\n" );
84 printf( " * definitions. Do not edit directly.\n" );
87 printf( "#ifndef __ASM_TYPES_H__\n" );
88 printf( "#define __ASM_TYPES_H__\n" );
90 printf( "#include \"assyntax.h\"\n" );
95 OFFSET_HEADER( "GLcontext" );
97 OFFSET( "CTX_DRIVER_CTX ", GLcontext
, DriverCtx
);
99 OFFSET( "CTX_LIGHT_ENABLED ", GLcontext
, Light
.Enabled
);
100 OFFSET( "CTX_LIGHT_SHADE_MODEL ", GLcontext
, Light
.ShadeModel
);
101 OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", GLcontext
, Light
.ColorMaterialFace
);
102 OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", GLcontext
, Light
.ColorMaterialMode
);
103 OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", GLcontext
, Light
.ColorMaterialBitmask
);
104 OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", GLcontext
, Light
.ColorMaterialEnabled
);
105 OFFSET( "CTX_LIGHT_ENABLED_LIST ", GLcontext
, Light
.EnabledList
);
106 OFFSET( "CTX_LIGHT_NEED_VERTS ", GLcontext
, Light
._NeedVertices
);
107 OFFSET( "CTX_LIGHT_FLAGS ", GLcontext
, Light
._Flags
);
108 OFFSET( "CTX_LIGHT_BASE_COLOR ", GLcontext
, Light
._BaseColor
);
111 /* struct vertex_buffer offsets:
113 OFFSET_HEADER( "struct vertex_buffer" );
115 OFFSET( "VB_SIZE ", struct vertex_buffer
, Size
);
116 OFFSET( "VB_COUNT ", struct vertex_buffer
, Count
);
118 OFFSET( "VB_FIRST_CLIPPED ", struct vertex_buffer
, FirstClipped
);
119 OFFSET( "VB_FIRST_PRIMITIVE ", struct vertex_buffer
, FirstPrimitive
);
121 OFFSET( "VB_ELTS ", struct vertex_buffer
, Elts
);
122 OFFSET( "VB_OBJ_PTR ", struct vertex_buffer
, ObjPtr
);
123 OFFSET( "VB_EYE_PTR ", struct vertex_buffer
, EyePtr
);
124 OFFSET( "VB_CLIP_PTR ", struct vertex_buffer
, ClipPtr
);
125 OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer
, ProjectedClipPtr
);
126 OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer
, ClipOrMask
);
127 OFFSET( "VB_CLIP_MASK ", struct vertex_buffer
, ClipMask
);
128 OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer
, NormalPtr
);
129 OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer
, EdgeFlag
);
130 OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer
, TexCoordPtr
[0] );
131 OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer
, TexCoordPtr
[1] );
132 OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer
, TexCoordPtr
[2] );
133 OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer
, TexCoordPtr
[3] );
134 OFFSET( "VB_INDEX_PTR ", struct vertex_buffer
, IndexPtr
);
135 OFFSET( "VB_COLOR_PTR ", struct vertex_buffer
, ColorPtr
);
136 OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer
, SecondaryColorPtr
);
137 OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer
, FogCoordPtr
);
138 OFFSET( "VB_POINT_SIZE_PTR ", struct vertex_buffer
, PointSizePtr
);
139 OFFSET( "VB_MATERIAL ", struct vertex_buffer
, Material
);
140 OFFSET( "VB_MATERIAL_MASK ", struct vertex_buffer
, MaterialMask
);
141 OFFSET( "VB_FLAG ", struct vertex_buffer
, Flag
);
142 OFFSET( "VB_PRIMITIVE ", struct vertex_buffer
, Primitive
);
143 OFFSET( "VB_PRIMITIVE_LENGTH ", struct vertex_buffer
, PrimitiveLength
);
145 OFFSET( "VB_IMPORTABLE_DATA ", struct vertex_buffer
, importable_data
);
147 OFFSET( "VB_LAST_CLIPPED ", struct vertex_buffer
, LastClipped
);
149 DEFINE_HEADER( "struct vertex_buffer" );
151 DEFINE( "VERT_OBJ ", VERT_OBJ
);
152 DEFINE( "VERT_RGBA ", VERT_RGBA
);
153 DEFINE( "VERT_NORM ", VERT_NORM
);
154 DEFINE( "VERT_INDEX ", VERT_INDEX
);
155 DEFINE( "VERT_EDGE ", VERT_EDGE
);
156 DEFINE( "VERT_SPEC_RGB ", VERT_SPEC_RGB
);
157 DEFINE( "VERT_FOG_COORD ", VERT_FOG_COORD
);
158 DEFINE( "VERT_TEX0 ", VERT_TEX0
);
159 DEFINE( "VERT_TEX1 ", VERT_TEX1
);
160 DEFINE( "VERT_TEX2 ", VERT_TEX2
);
161 DEFINE( "VERT_TEX3 ", VERT_TEX3
);
162 DEFINE( "VERT_EVAL_C1 ", VERT_EVAL_C1
);
163 DEFINE( "VERT_EVAL_C2 ", VERT_EVAL_C2
);
164 DEFINE( "VERT_EVAL_P1 ", VERT_EVAL_P1
);
165 DEFINE( "VERT_EVAL_P2 ", VERT_EVAL_P2
);
166 DEFINE( "VERT_OBJ_3 ", VERT_OBJ_3
);
167 DEFINE( "VERT_OBJ_4 ", VERT_OBJ_4
);
168 DEFINE( "VERT_MATERIAL ", VERT_MATERIAL
);
169 DEFINE( "VERT_ELT ", VERT_ELT
);
170 DEFINE( "VERT_BEGIN ", VERT_BEGIN
);
171 DEFINE( "VERT_END ", VERT_END
);
172 DEFINE( "VERT_END_VB ", VERT_END_VB
);
173 DEFINE( "VERT_POINT_SIZE ", VERT_POINT_SIZE
);
174 DEFINE( "VERT_EYE ", VERT_EYE
);
175 DEFINE( "VERT_CLIP ", VERT_CLIP
);
177 DEFINE( "VERT_OBJ_23 ", VERT_OBJ_3
);
178 DEFINE( "VERT_OBJ_234 ", VERT_OBJ_4
);
181 /* GLvector3f offsets:
183 OFFSET_HEADER( "GLvector3f" );
185 OFFSET( "V3F_DATA ", GLvector3f
, data
);
186 OFFSET( "V3F_START ", GLvector3f
, start
);
187 OFFSET( "V3F_COUNT ", GLvector3f
, count
);
188 OFFSET( "V3F_STRIDE ", GLvector3f
, stride
);
189 OFFSET( "V3F_FLAGS ", GLvector3f
, flags
);
192 /* GLvector4f offsets:
194 OFFSET_HEADER( "GLvector4f" );
196 OFFSET( "V4F_DATA ", GLvector4f
, data
);
197 OFFSET( "V4F_START ", GLvector4f
, start
);
198 OFFSET( "V4F_COUNT ", GLvector4f
, count
);
199 OFFSET( "V4F_STRIDE ", GLvector4f
, stride
);
200 OFFSET( "V4F_SIZE ", GLvector4f
, size
);
201 OFFSET( "V4F_FLAGS ", GLvector4f
, flags
);
203 DEFINE_HEADER( "GLvector4f" );
205 DEFINE( "VEC_MALLOC ", VEC_MALLOC
);
206 DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE
);
207 DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE
);
209 DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1
);
210 DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2
);
211 DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3
);
212 DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4
);
217 OFFSET_HEADER( "GLmatrix" );
219 OFFSET( "MATRIX_DATA ", GLmatrix
, m
);
220 OFFSET( "MATRIX_INV ", GLmatrix
, inv
);
221 OFFSET( "MATRIX_FLAGS ", GLmatrix
, flags
);
222 OFFSET( "MATRIX_TYPE ", GLmatrix
, type
);
225 /* struct gl_light offsets:
227 OFFSET_HEADER( "struct gl_light" );
229 OFFSET( "LIGHT_NEXT ", struct gl_light
, next
);
230 OFFSET( "LIGHT_PREV ", struct gl_light
, prev
);
232 OFFSET( "LIGHT_AMBIENT ", struct gl_light
, Ambient
);
233 OFFSET( "LIGHT_DIFFUSE ", struct gl_light
, Diffuse
);
234 OFFSET( "LIGHT_SPECULAR ", struct gl_light
, Specular
);
235 OFFSET( "LIGHT_EYE_POSITION ", struct gl_light
, EyePosition
);
236 OFFSET( "LIGHT_EYE_DIRECTION ", struct gl_light
, EyeDirection
);
237 OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light
, SpotExponent
);
238 OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light
, SpotCutoff
);
239 OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light
, _CosCutoff
);
240 OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light
, ConstantAttenuation
);
241 OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light
, LinearAttenuation
);
242 OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light
, QuadraticAttenuation
);
243 OFFSET( "LIGHT_ENABLED ", struct gl_light
, Enabled
);
245 OFFSET( "LIGHT_FLAGS ", struct gl_light
, _Flags
);
247 OFFSET( "LIGHT_POSITION ", struct gl_light
, _Position
);
248 OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light
, _VP_inf_norm
);
249 OFFSET( "LIGHT_H_INF_NORM ", struct gl_light
, _h_inf_norm
);
250 OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light
, _NormDirection
);
251 OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light
, _VP_inf_spot_attenuation
);
253 OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light
, _SpotExpTable
);
254 OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light
, _MatAmbient
);
255 OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light
, _MatDiffuse
);
256 OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light
, _MatSpecular
);
258 SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light
);
260 DEFINE_HEADER( "struct gl_light" );
262 DEFINE( "LIGHT_SPOT ", LIGHT_SPOT
);
263 DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER
);
264 DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL
);
266 DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES
);
269 /* struct gl_lightmodel offsets:
271 OFFSET_HEADER( "struct gl_lightmodel" );
273 OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel
, Ambient
);
274 OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel
, LocalViewer
);
275 OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel
, TwoSide
);
276 OFFSET( "LIGHT_MODEL_COLOR_CONTROL ", struct gl_lightmodel
, ColorControl
);
281 printf( "#endif /* __ASM_TYPES_H__ */\n" );