1 /* $Id: gen_matypes.c,v 1.8 2002/09/19 16:19:45 brianp 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 ); \
70 #define OFFSET( s, t, m ) \
71 printf( "#define %s\t%ld\n", s, offsetof( t, m ) );
73 #define OFFSET( s, t, m ) \
74 printf( "#define %s\t%d\n", s, offsetof( t, m ) );
78 #define SIZEOF( s, t ) \
79 printf( "#define %s\t%ld\n", s, sizeof(t) );
81 #define SIZEOF( s, t ) \
82 printf( "#define %s\t%d\n", s, sizeof(t) );
85 #define DEFINE( s, d ) \
86 printf( "#define %s\t0x%x\n", s, d );
90 int main( int argc
, char **argv
)
93 printf( " * This file is automatically generated from the Mesa internal type\n" );
94 printf( " * definitions. Do not edit directly.\n" );
97 printf( "#ifndef __ASM_TYPES_H__\n" );
98 printf( "#define __ASM_TYPES_H__\n" );
100 printf( "#include \"assyntax.h\"\n" );
103 /* GLcontext offsets:
105 OFFSET_HEADER( "GLcontext" );
107 OFFSET( "CTX_DRIVER_CTX ", GLcontext
, DriverCtx
);
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
);
121 /* struct vertex_buffer offsets:
123 OFFSET_HEADER( "struct vertex_buffer" );
125 OFFSET( "VB_SIZE ", struct vertex_buffer
, Size
);
126 OFFSET( "VB_COUNT ", struct vertex_buffer
, Count
);
128 OFFSET( "VB_FIRST_CLIPPED ", struct vertex_buffer
, FirstClipped
);
129 OFFSET( "VB_FIRST_PRIMITIVE ", struct vertex_buffer
, FirstPrimitive
);
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
);
155 OFFSET( "VB_IMPORTABLE_DATA ", struct vertex_buffer
, importable_data
);
157 OFFSET( "VB_LAST_CLIPPED ", struct vertex_buffer
, LastClipped
);
159 DEFINE_HEADER( "struct vertex_buffer" );
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
);
188 DEFINE( "VERT_BIT_OBJ_23 ", VERT_BIT_OBJ_3
);
189 DEFINE( "VERT_BIT_OBJ_234 ", VERT_BIT_OBJ_4
);
192 /* GLvector3f offsets:
194 OFFSET_HEADER( "GLvector3f" );
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
);
203 /* GLvector4f offsets:
205 OFFSET_HEADER( "GLvector4f" );
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
);
214 DEFINE_HEADER( "GLvector4f" );
216 DEFINE( "VEC_MALLOC ", VEC_MALLOC
);
217 DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE
);
218 DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE
);
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
);
228 OFFSET_HEADER( "GLmatrix" );
230 OFFSET( "MATRIX_DATA ", GLmatrix
, m
);
231 OFFSET( "MATRIX_INV ", GLmatrix
, inv
);
232 OFFSET( "MATRIX_FLAGS ", GLmatrix
, flags
);
233 OFFSET( "MATRIX_TYPE ", GLmatrix
, type
);
236 /* struct gl_light offsets:
238 OFFSET_HEADER( "struct gl_light" );
240 OFFSET( "LIGHT_NEXT ", struct gl_light
, next
);
241 OFFSET( "LIGHT_PREV ", struct gl_light
, prev
);
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
);
256 OFFSET( "LIGHT_FLAGS ", struct gl_light
, _Flags
);
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
);
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
);
269 SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light
);
271 DEFINE_HEADER( "struct gl_light" );
273 DEFINE( "LIGHT_SPOT ", LIGHT_SPOT
);
274 DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER
);
275 DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL
);
277 DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES
);
280 /* struct gl_lightmodel offsets:
282 OFFSET_HEADER( "struct gl_lightmodel" );
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
);
292 printf( "#endif /* __ASM_TYPES_H__ */\n" );