2 * Mesa 3-D graphics library
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
11 * and/or sell copies of the Software, and to permit persons to whom the
12 * Software is furnished to do so, subject to the following conditions:
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
21 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
22 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
29 * This generates an asm version of mtypes.h (called matypes.h), so that
30 * Mesa's x86 assembly code can access the internal structures easily.
31 * This will be particularly useful when developing new x86 asm code for
32 * Mesa, including lighting, clipping, texture image conversion etc.
35 #include "main/glheader.h"
36 #include "main/mtypes.h"
37 #include "tnl/t_context.h"
41 #define offsetof( type, member ) ((size_t) &((type *)0)->member)
44 #define OFFSET_HEADER( x ) \
48 printf( "/* =====================================================" \
50 printf( " * Offsets for %s\n", x ); \
55 #define DEFINE_HEADER( x ) \
59 printf( " * Flags for %s\n", x ); \
64 #define OFFSET( s, t, m ) \
65 printf( "#define %s\t%lu\n", s, (unsigned long) offsetof( t, m ) );
67 #define SIZEOF( s, t ) \
68 printf( "#define %s\t%lu\n", s, (unsigned long) sizeof(t) );
70 #define DEFINE( s, d ) \
71 printf( "#define %s\t0x%x\n", s, d );
75 int main( int argc
, char **argv
)
78 printf( " * This file is automatically generated from the Mesa internal type\n" );
79 printf( " * definitions. Do not edit directly.\n" );
82 printf( "#ifndef __ASM_TYPES_H__\n" );
83 printf( "#define __ASM_TYPES_H__\n" );
89 OFFSET_HEADER( "GLcontext" );
91 OFFSET( "CTX_DRIVER_CTX ", GLcontext
, DriverCtx
);
93 OFFSET( "CTX_LIGHT_ENABLED ", GLcontext
, Light
.Enabled
);
94 OFFSET( "CTX_LIGHT_SHADE_MODEL ", GLcontext
, Light
.ShadeModel
);
95 OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", GLcontext
, Light
.ColorMaterialFace
);
96 OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", GLcontext
, Light
.ColorMaterialMode
);
97 OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", GLcontext
, Light
.ColorMaterialBitmask
);
98 OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", GLcontext
, Light
.ColorMaterialEnabled
);
99 OFFSET( "CTX_LIGHT_ENABLED_LIST ", GLcontext
, Light
.EnabledList
);
100 OFFSET( "CTX_LIGHT_NEED_VERTS ", GLcontext
, Light
._NeedVertices
);
101 OFFSET( "CTX_LIGHT_FLAGS ", GLcontext
, Light
._Flags
);
102 OFFSET( "CTX_LIGHT_BASE_COLOR ", GLcontext
, Light
._BaseColor
);
105 /* struct vertex_buffer offsets:
107 OFFSET_HEADER( "struct vertex_buffer" );
109 OFFSET( "VB_SIZE ", struct vertex_buffer
, Size
);
110 OFFSET( "VB_COUNT ", struct vertex_buffer
, Count
);
112 OFFSET( "VB_ELTS ", struct vertex_buffer
, Elts
);
113 OFFSET( "VB_OBJ_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_POS
] );
114 OFFSET( "VB_EYE_PTR ", struct vertex_buffer
, EyePtr
);
115 OFFSET( "VB_CLIP_PTR ", struct vertex_buffer
, ClipPtr
);
116 OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer
, NdcPtr
);
117 OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer
, ClipOrMask
);
118 OFFSET( "VB_CLIP_MASK ", struct vertex_buffer
, ClipMask
);
119 OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_NORMAL
] );
120 OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer
, EdgeFlag
);
121 OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX0
] );
122 OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX1
] );
123 OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX2
] );
124 OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX3
] );
125 OFFSET( "VB_INDEX_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_COLOR_INDEX
] );
126 OFFSET( "VB_COLOR_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_COLOR0
] );
127 OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_COLOR1
] );
128 OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_FOG
] );
129 OFFSET( "VB_PRIMITIVE ", struct vertex_buffer
, Primitive
);
132 DEFINE_HEADER( "struct vertex_buffer" );
134 /* XXX use new labels here someday after vertex proram is done */
135 DEFINE( "VERT_BIT_OBJ ", VERT_BIT_POS
);
136 DEFINE( "VERT_BIT_NORM ", VERT_BIT_NORMAL
);
137 DEFINE( "VERT_BIT_RGBA ", VERT_BIT_COLOR0
);
138 DEFINE( "VERT_BIT_SPEC_RGB ", VERT_BIT_COLOR1
);
139 DEFINE( "VERT_BIT_FOG_COORD ", VERT_BIT_FOG
);
140 DEFINE( "VERT_BIT_TEX0 ", VERT_BIT_TEX0
);
141 DEFINE( "VERT_BIT_TEX1 ", VERT_BIT_TEX1
);
142 DEFINE( "VERT_BIT_TEX2 ", VERT_BIT_TEX2
);
143 DEFINE( "VERT_BIT_TEX3 ", VERT_BIT_TEX3
);
146 /* GLvector4f offsets:
148 OFFSET_HEADER( "GLvector4f" );
150 OFFSET( "V4F_DATA ", GLvector4f
, data
);
151 OFFSET( "V4F_START ", GLvector4f
, start
);
152 OFFSET( "V4F_COUNT ", GLvector4f
, count
);
153 OFFSET( "V4F_STRIDE ", GLvector4f
, stride
);
154 OFFSET( "V4F_SIZE ", GLvector4f
, size
);
155 OFFSET( "V4F_FLAGS ", GLvector4f
, flags
);
157 DEFINE_HEADER( "GLvector4f" );
159 DEFINE( "VEC_MALLOC ", VEC_MALLOC
);
160 DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE
);
161 DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE
);
163 DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1
);
164 DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2
);
165 DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3
);
166 DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4
);
171 OFFSET_HEADER( "GLmatrix" );
173 OFFSET( "MATRIX_DATA ", GLmatrix
, m
);
174 OFFSET( "MATRIX_INV ", GLmatrix
, inv
);
175 OFFSET( "MATRIX_FLAGS ", GLmatrix
, flags
);
176 OFFSET( "MATRIX_TYPE ", GLmatrix
, type
);
179 /* struct gl_light offsets:
181 OFFSET_HEADER( "struct gl_light" );
183 OFFSET( "LIGHT_NEXT ", struct gl_light
, next
);
184 OFFSET( "LIGHT_PREV ", struct gl_light
, prev
);
186 OFFSET( "LIGHT_AMBIENT ", struct gl_light
, Ambient
);
187 OFFSET( "LIGHT_DIFFUSE ", struct gl_light
, Diffuse
);
188 OFFSET( "LIGHT_SPECULAR ", struct gl_light
, Specular
);
189 OFFSET( "LIGHT_EYE_POSITION ", struct gl_light
, EyePosition
);
190 OFFSET( "LIGHT_SPOT_DIRECTION ", struct gl_light
, SpotDirection
);
191 OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light
, SpotExponent
);
192 OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light
, SpotCutoff
);
193 OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light
, _CosCutoff
);
194 OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light
, ConstantAttenuation
);
195 OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light
, LinearAttenuation
);
196 OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light
, QuadraticAttenuation
);
197 OFFSET( "LIGHT_ENABLED ", struct gl_light
, Enabled
);
199 OFFSET( "LIGHT_FLAGS ", struct gl_light
, _Flags
);
201 OFFSET( "LIGHT_POSITION ", struct gl_light
, _Position
);
202 OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light
, _VP_inf_norm
);
203 OFFSET( "LIGHT_H_INF_NORM ", struct gl_light
, _h_inf_norm
);
204 OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light
, _NormSpotDirection
);
205 OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light
, _VP_inf_spot_attenuation
);
207 OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light
, _SpotExpTable
);
208 OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light
, _MatAmbient
);
209 OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light
, _MatDiffuse
);
210 OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light
, _MatSpecular
);
212 SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light
);
214 DEFINE_HEADER( "struct gl_light" );
216 DEFINE( "LIGHT_SPOT ", LIGHT_SPOT
);
217 DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER
);
218 DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL
);
220 DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES
);
223 /* struct gl_lightmodel offsets:
225 OFFSET_HEADER( "struct gl_lightmodel" );
227 OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel
, Ambient
);
228 OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel
, LocalViewer
);
229 OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel
, TwoSide
);
230 OFFSET( "LIGHT_MODEL_COLOR_CONTROL ", struct gl_lightmodel
, ColorControl
);
235 printf( "#endif /* __ASM_TYPES_H__ */\n" );