2 * Mesa 3-D graphics library
4 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 * Permission is hereby granted, free of charge, to any person obtaining a
7 * copy of this software and associated documentation files (the "Software"),
8 * to deal in the Software without restriction, including without limitation
9 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
10 * and/or sell copies of the Software, and to permit persons to whom the
11 * Software is furnished to do so, subject to the following conditions:
13 * The above copyright notice and this permission notice shall be included
14 * in all copies or substantial portions of the Software.
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
17 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
19 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
20 * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
21 * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
22 * 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 #ifndef __STDC_FORMAT_MACROS
36 #define __STDC_FORMAT_MACROS
42 #include "main/glheader.h"
43 #include "main/mtypes.h"
44 #include "tnl/t_context.h"
48 #define offsetof( type, member ) ((size_t) &((type *)0)->member)
51 #define OFFSET_HEADER( x ) \
55 printf( "/* =====================================================" \
57 printf( " * Offsets for " x "\n" ); \
62 #define DEFINE_HEADER( x ) \
66 printf( " * Flags for " x "\n" ); \
74 * Format the asm output in a special way that we can manipulate
75 * after the fact and turn into the final header for the target.
78 #define DEFINE_UL( s, ul ) \
79 __asm__ __volatile__ ( "\n->" s " %0" : : "i" (ul) )
81 #define DEFINE( s, d ) \
85 __asm__ __volatile__ ( "\n->" x )
89 #define DEFINE_UL( s, ul ) \
90 printf( "#define %s\t%lu\n", s, (unsigned long) (ul) );
92 #define DEFINE( s, d ) \
93 printf( "#define %s\t0x%" PRIx64 "\n", s, (uint64_t) d );
97 #define OFFSET( s, t, m ) \
98 DEFINE_UL( s, offsetof( t, m ) )
100 #define SIZEOF( s, t ) \
101 DEFINE_UL( s, sizeof(t) )
105 int main( int argc
, char **argv
)
108 printf( " * This file is automatically generated from the Mesa internal type\n" );
109 printf( " * definitions. Do not edit directly.\n" );
112 printf( "#ifndef __ASM_TYPES_H__\n" );
113 printf( "#define __ASM_TYPES_H__\n" );
117 /* struct gl_context offsets:
119 OFFSET_HEADER( "struct gl_context" );
122 OFFSET( "CTX_LIGHT_ENABLED ", struct gl_context
, Light
.Enabled
);
123 OFFSET( "CTX_LIGHT_SHADE_MODEL ", struct gl_context
, Light
.ShadeModel
);
124 OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", struct gl_context
, Light
.ColorMaterialFace
);
125 OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", struct gl_context
, Light
.ColorMaterialMode
);
126 OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", struct gl_context
, Light
._ColorMaterialBitmask
);
127 OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", struct gl_context
, Light
.ColorMaterialEnabled
);
128 OFFSET( "CTX_LIGHT_ENABLED_LIST ", struct gl_context
, Light
.EnabledList
);
129 OFFSET( "CTX_LIGHT_NEED_VERTS ", struct gl_context
, Light
._NeedVertices
);
130 OFFSET( "CTX_LIGHT_BASE_COLOR ", struct gl_context
, Light
._BaseColor
);
133 /* struct vertex_buffer offsets:
135 OFFSET_HEADER( "struct vertex_buffer" );
137 OFFSET( "VB_SIZE ", struct vertex_buffer
, Size
);
138 OFFSET( "VB_COUNT ", struct vertex_buffer
, Count
);
140 OFFSET( "VB_ELTS ", struct vertex_buffer
, Elts
);
141 OFFSET( "VB_OBJ_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_POS
] );
142 OFFSET( "VB_EYE_PTR ", struct vertex_buffer
, EyePtr
);
143 OFFSET( "VB_CLIP_PTR ", struct vertex_buffer
, ClipPtr
);
144 OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer
, NdcPtr
);
145 OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer
, ClipOrMask
);
146 OFFSET( "VB_CLIP_MASK ", struct vertex_buffer
, ClipMask
);
147 OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_NORMAL
] );
148 OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer
, EdgeFlag
);
149 OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX0
] );
150 OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX1
] );
151 OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX2
] );
152 OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX3
] );
153 OFFSET( "VB_INDEX_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_COLOR_INDEX
] );
154 OFFSET( "VB_COLOR_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_COLOR0
] );
155 OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_COLOR1
] );
156 OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_FOG
] );
157 OFFSET( "VB_PRIMITIVE ", struct vertex_buffer
, Primitive
);
160 DEFINE_HEADER( "struct vertex_buffer" );
162 /* XXX use new labels here someday after vertex proram is done */
163 DEFINE( "VERT_BIT_OBJ ", VERT_BIT_POS
);
164 DEFINE( "VERT_BIT_NORM ", VERT_BIT_NORMAL
);
165 DEFINE( "VERT_BIT_RGBA ", VERT_BIT_COLOR0
);
166 DEFINE( "VERT_BIT_SPEC_RGB ", VERT_BIT_COLOR1
);
167 DEFINE( "VERT_BIT_FOG_COORD ", VERT_BIT_FOG
);
168 DEFINE( "VERT_BIT_TEX0 ", VERT_BIT_TEX0
);
169 DEFINE( "VERT_BIT_TEX1 ", VERT_BIT_TEX1
);
170 DEFINE( "VERT_BIT_TEX2 ", VERT_BIT_TEX2
);
171 DEFINE( "VERT_BIT_TEX3 ", VERT_BIT_TEX3
);
174 /* GLvector4f offsets:
176 OFFSET_HEADER( "GLvector4f" );
178 OFFSET( "V4F_DATA ", GLvector4f
, data
);
179 OFFSET( "V4F_START ", GLvector4f
, start
);
180 OFFSET( "V4F_COUNT ", GLvector4f
, count
);
181 OFFSET( "V4F_STRIDE ", GLvector4f
, stride
);
182 OFFSET( "V4F_SIZE ", GLvector4f
, size
);
183 OFFSET( "V4F_FLAGS ", GLvector4f
, flags
);
185 DEFINE_HEADER( "GLvector4f" );
187 DEFINE( "VEC_MALLOC ", VEC_MALLOC
);
188 DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE
);
189 DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE
);
191 DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1
);
192 DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2
);
193 DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3
);
194 DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4
);
199 OFFSET_HEADER( "GLmatrix" );
201 OFFSET( "MATRIX_DATA ", GLmatrix
, m
);
202 OFFSET( "MATRIX_INV ", GLmatrix
, inv
);
203 OFFSET( "MATRIX_FLAGS ", GLmatrix
, flags
);
204 OFFSET( "MATRIX_TYPE ", GLmatrix
, type
);
207 /* struct gl_light offsets:
209 OFFSET_HEADER( "struct gl_light" );
211 OFFSET( "LIGHT_NEXT ", struct gl_light
, next
);
212 OFFSET( "LIGHT_PREV ", struct gl_light
, prev
);
214 OFFSET( "LIGHT_AMBIENT ", struct gl_light
, Ambient
);
215 OFFSET( "LIGHT_DIFFUSE ", struct gl_light
, Diffuse
);
216 OFFSET( "LIGHT_SPECULAR ", struct gl_light
, Specular
);
217 OFFSET( "LIGHT_EYE_POSITION ", struct gl_light
, EyePosition
);
218 OFFSET( "LIGHT_SPOT_DIRECTION ", struct gl_light
, SpotDirection
);
219 OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light
, SpotExponent
);
220 OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light
, SpotCutoff
);
221 OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light
, _CosCutoff
);
222 OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light
, ConstantAttenuation
);
223 OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light
, LinearAttenuation
);
224 OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light
, QuadraticAttenuation
);
225 OFFSET( "LIGHT_ENABLED ", struct gl_light
, Enabled
);
227 OFFSET( "LIGHT_FLAGS ", struct gl_light
, _Flags
);
229 OFFSET( "LIGHT_POSITION ", struct gl_light
, _Position
);
230 OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light
, _VP_inf_norm
);
231 OFFSET( "LIGHT_H_INF_NORM ", struct gl_light
, _h_inf_norm
);
232 OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light
, _NormSpotDirection
);
233 OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light
, _VP_inf_spot_attenuation
);
235 OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light
, _MatAmbient
);
236 OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light
, _MatDiffuse
);
237 OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light
, _MatSpecular
);
239 SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light
);
241 DEFINE_HEADER( "struct gl_light" );
243 DEFINE( "LIGHT_SPOT ", LIGHT_SPOT
);
244 DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER
);
245 DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL
);
247 DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES
);
250 /* struct gl_lightmodel offsets:
252 OFFSET_HEADER( "struct gl_lightmodel" );
254 OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel
, Ambient
);
255 OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel
, LocalViewer
);
256 OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel
, TwoSide
);
257 OFFSET( "LIGHT_MODEL_COLOR_CONTROL ", struct gl_lightmodel
, ColorControl
);
262 printf( "#endif /* __ASM_TYPES_H__ */\n" );