1 /* $Id: gen_matypes.c,v 1.10 2002/10/29 20:28:58 brianp Exp $ */
4 * Mesa 3-D graphics library
7 * Copyright (C) 1999-2002 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.
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.
39 #include "tnl/t_context.h"
43 #define offsetof( type, member ) ((size_t) &((type *)0)->member)
46 #define OFFSET_HEADER( x ) \
50 printf( "/* =====================================================" \
52 printf( " * Offsets for %s\n", x ); \
57 #define DEFINE_HEADER( x ) \
61 printf( " * Flags for %s\n", x ); \
67 #define OFFSET( s, t, m ) \
68 printf( "#define %s\t%ld\n", s, offsetof( t, m ) );
70 #define OFFSET( s, t, m ) \
71 printf( "#define %s\t%d\n", s, offsetof( t, m ) );
75 #define SIZEOF( s, t ) \
76 printf( "#define %s\t%ld\n", s, sizeof(t) );
78 #define SIZEOF( s, t ) \
79 printf( "#define %s\t%d\n", s, sizeof(t) );
82 #define DEFINE( s, d ) \
83 printf( "#define %s\t0x%x\n", s, d );
87 int main( int argc
, char **argv
)
90 printf( " * This file is automatically generated from the Mesa internal type\n" );
91 printf( " * definitions. Do not edit directly.\n" );
94 printf( "#ifndef __ASM_TYPES_H__\n" );
95 printf( "#define __ASM_TYPES_H__\n" );
97 printf( "#include \"assyntax.h\"\n" );
100 /* GLcontext offsets:
102 OFFSET_HEADER( "GLcontext" );
104 OFFSET( "CTX_DRIVER_CTX ", GLcontext
, DriverCtx
);
106 OFFSET( "CTX_LIGHT_ENABLED ", GLcontext
, Light
.Enabled
);
107 OFFSET( "CTX_LIGHT_SHADE_MODEL ", GLcontext
, Light
.ShadeModel
);
108 OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", GLcontext
, Light
.ColorMaterialFace
);
109 OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", GLcontext
, Light
.ColorMaterialMode
);
110 OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", GLcontext
, Light
.ColorMaterialBitmask
);
111 OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", GLcontext
, Light
.ColorMaterialEnabled
);
112 OFFSET( "CTX_LIGHT_ENABLED_LIST ", GLcontext
, Light
.EnabledList
);
113 OFFSET( "CTX_LIGHT_NEED_VERTS ", GLcontext
, Light
._NeedVertices
);
114 OFFSET( "CTX_LIGHT_FLAGS ", GLcontext
, Light
._Flags
);
115 OFFSET( "CTX_LIGHT_BASE_COLOR ", GLcontext
, Light
._BaseColor
);
118 /* struct vertex_buffer offsets:
120 OFFSET_HEADER( "struct vertex_buffer" );
122 OFFSET( "VB_SIZE ", struct vertex_buffer
, Size
);
123 OFFSET( "VB_COUNT ", struct vertex_buffer
, Count
);
125 OFFSET( "VB_FIRST_CLIPPED ", struct vertex_buffer
, FirstClipped
);
126 OFFSET( "VB_FIRST_PRIMITIVE ", struct vertex_buffer
, FirstPrimitive
);
128 OFFSET( "VB_ELTS ", struct vertex_buffer
, Elts
);
129 OFFSET( "VB_OBJ_PTR ", struct vertex_buffer
, ObjPtr
);
130 OFFSET( "VB_EYE_PTR ", struct vertex_buffer
, EyePtr
);
131 OFFSET( "VB_CLIP_PTR ", struct vertex_buffer
, ClipPtr
);
132 OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer
, NdcPtr
);
133 OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer
, ClipOrMask
);
134 OFFSET( "VB_CLIP_MASK ", struct vertex_buffer
, ClipMask
);
135 OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer
, NormalPtr
);
136 OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer
, EdgeFlag
);
137 OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer
, TexCoordPtr
[0] );
138 OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer
, TexCoordPtr
[1] );
139 OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer
, TexCoordPtr
[2] );
140 OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer
, TexCoordPtr
[3] );
141 OFFSET( "VB_INDEX_PTR ", struct vertex_buffer
, IndexPtr
);
142 OFFSET( "VB_COLOR_PTR ", struct vertex_buffer
, ColorPtr
);
143 OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer
, SecondaryColorPtr
);
144 OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer
, FogCoordPtr
);
145 OFFSET( "VB_POINT_SIZE_PTR ", struct vertex_buffer
, PointSizePtr
);
146 OFFSET( "VB_MATERIAL ", struct vertex_buffer
, Material
);
147 OFFSET( "VB_MATERIAL_MASK ", struct vertex_buffer
, MaterialMask
);
148 OFFSET( "VB_FLAG ", struct vertex_buffer
, Flag
);
149 OFFSET( "VB_PRIMITIVE ", struct vertex_buffer
, Primitive
);
150 OFFSET( "VB_PRIMITIVE_LENGTH ", struct vertex_buffer
, PrimitiveLength
);
152 OFFSET( "VB_IMPORTABLE_DATA ", struct vertex_buffer
, importable_data
);
154 OFFSET( "VB_LAST_CLIPPED ", struct vertex_buffer
, LastClipped
);
156 DEFINE_HEADER( "struct vertex_buffer" );
158 /* XXX use new labels here someday after vertex proram is done */
159 DEFINE( "VERT_BIT_OBJ ", VERT_BIT_POS
);
160 DEFINE( "VERT_BIT_NORM ", VERT_BIT_NORMAL
);
161 DEFINE( "VERT_BIT_RGBA ", VERT_BIT_COLOR0
);
162 DEFINE( "VERT_BIT_SPEC_RGB ", VERT_BIT_COLOR1
);
163 DEFINE( "VERT_BIT_FOG_COORD ", VERT_BIT_FOG
);
164 DEFINE( "VERT_BIT_INDEX ", VERT_BIT_INDEX
);
165 DEFINE( "VERT_BIT_EDGE ", VERT_BIT_EDGEFLAG
);
166 DEFINE( "VERT_BIT_TEX0 ", VERT_BIT_TEX0
);
167 DEFINE( "VERT_BIT_TEX1 ", VERT_BIT_TEX1
);
168 DEFINE( "VERT_BIT_TEX2 ", VERT_BIT_TEX2
);
169 DEFINE( "VERT_BIT_TEX3 ", VERT_BIT_TEX3
);
170 DEFINE( "VERT_BIT_EVAL_C1 ", VERT_BIT_EVAL_C1
);
171 DEFINE( "VERT_BIT_EVAL_C2 ", VERT_BIT_EVAL_C2
);
172 DEFINE( "VERT_BIT_EVAL_P1 ", VERT_BIT_EVAL_P1
);
173 DEFINE( "VERT_BIT_EVAL_P2 ", VERT_BIT_EVAL_P2
);
174 DEFINE( "VERT_BIT_OBJ_3 ", VERT_BIT_OBJ_3
);
175 DEFINE( "VERT_BIT_OBJ_4 ", VERT_BIT_OBJ_4
);
176 DEFINE( "VERT_BIT_MATERIAL ", VERT_BIT_MATERIAL
);
177 DEFINE( "VERT_BIT_ELT ", VERT_BIT_ELT
);
178 DEFINE( "VERT_BIT_BEGIN ", VERT_BIT_BEGIN
);
179 DEFINE( "VERT_BIT_END ", VERT_BIT_END
);
180 DEFINE( "VERT_BIT_END_VB ", VERT_BIT_END_VB
);
181 DEFINE( "VERT_BIT_POINT_SIZE ", VERT_BIT_POINT_SIZE
);
182 DEFINE( "VERT_BIT_EYE ", VERT_BIT_EYE
);
183 DEFINE( "VERT_BIT_CLIP ", VERT_BIT_CLIP
);
185 DEFINE( "VERT_BIT_OBJ_23 ", VERT_BIT_OBJ_3
);
186 DEFINE( "VERT_BIT_OBJ_234 ", VERT_BIT_OBJ_4
);
189 /* GLvector3f offsets:
191 OFFSET_HEADER( "GLvector3f" );
193 OFFSET( "V3F_DATA ", GLvector3f
, data
);
194 OFFSET( "V3F_START ", GLvector3f
, start
);
195 OFFSET( "V3F_COUNT ", GLvector3f
, count
);
196 OFFSET( "V3F_STRIDE ", GLvector3f
, stride
);
197 OFFSET( "V3F_FLAGS ", GLvector3f
, flags
);
200 /* GLvector4f offsets:
202 OFFSET_HEADER( "GLvector4f" );
204 OFFSET( "V4F_DATA ", GLvector4f
, data
);
205 OFFSET( "V4F_START ", GLvector4f
, start
);
206 OFFSET( "V4F_COUNT ", GLvector4f
, count
);
207 OFFSET( "V4F_STRIDE ", GLvector4f
, stride
);
208 OFFSET( "V4F_SIZE ", GLvector4f
, size
);
209 OFFSET( "V4F_FLAGS ", GLvector4f
, flags
);
211 DEFINE_HEADER( "GLvector4f" );
213 DEFINE( "VEC_MALLOC ", VEC_MALLOC
);
214 DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE
);
215 DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE
);
217 DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1
);
218 DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2
);
219 DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3
);
220 DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4
);
225 OFFSET_HEADER( "GLmatrix" );
227 OFFSET( "MATRIX_DATA ", GLmatrix
, m
);
228 OFFSET( "MATRIX_INV ", GLmatrix
, inv
);
229 OFFSET( "MATRIX_FLAGS ", GLmatrix
, flags
);
230 OFFSET( "MATRIX_TYPE ", GLmatrix
, type
);
233 /* struct gl_light offsets:
235 OFFSET_HEADER( "struct gl_light" );
237 OFFSET( "LIGHT_NEXT ", struct gl_light
, next
);
238 OFFSET( "LIGHT_PREV ", struct gl_light
, prev
);
240 OFFSET( "LIGHT_AMBIENT ", struct gl_light
, Ambient
);
241 OFFSET( "LIGHT_DIFFUSE ", struct gl_light
, Diffuse
);
242 OFFSET( "LIGHT_SPECULAR ", struct gl_light
, Specular
);
243 OFFSET( "LIGHT_EYE_POSITION ", struct gl_light
, EyePosition
);
244 OFFSET( "LIGHT_EYE_DIRECTION ", struct gl_light
, EyeDirection
);
245 OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light
, SpotExponent
);
246 OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light
, SpotCutoff
);
247 OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light
, _CosCutoff
);
248 OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light
, ConstantAttenuation
);
249 OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light
, LinearAttenuation
);
250 OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light
, QuadraticAttenuation
);
251 OFFSET( "LIGHT_ENABLED ", struct gl_light
, Enabled
);
253 OFFSET( "LIGHT_FLAGS ", struct gl_light
, _Flags
);
255 OFFSET( "LIGHT_POSITION ", struct gl_light
, _Position
);
256 OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light
, _VP_inf_norm
);
257 OFFSET( "LIGHT_H_INF_NORM ", struct gl_light
, _h_inf_norm
);
258 OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light
, _NormDirection
);
259 OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light
, _VP_inf_spot_attenuation
);
261 OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light
, _SpotExpTable
);
262 OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light
, _MatAmbient
);
263 OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light
, _MatDiffuse
);
264 OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light
, _MatSpecular
);
266 SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light
);
268 DEFINE_HEADER( "struct gl_light" );
270 DEFINE( "LIGHT_SPOT ", LIGHT_SPOT
);
271 DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER
);
272 DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL
);
274 DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES
);
277 /* struct gl_lightmodel offsets:
279 OFFSET_HEADER( "struct gl_lightmodel" );
281 OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel
, Ambient
);
282 OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel
, LocalViewer
);
283 OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel
, TwoSide
);
284 OFFSET( "LIGHT_MODEL_COLOR_CONTROL ", struct gl_lightmodel
, ColorControl
);
289 printf( "#endif /* __ASM_TYPES_H__ */\n" );