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
40 #include "main/glheader.h"
41 #include "main/mtypes.h"
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 " x "\n" ); \
60 #define DEFINE_HEADER( x ) \
64 printf( " * Flags for " x "\n" ); \
72 * Format the asm output in a special way that we can manipulate
73 * after the fact and turn into the final header for the target.
76 #define DEFINE_UL( s, ul ) \
77 __asm__ __volatile__ ( "\n->" s " %0" : : "i" (ul) )
79 #define DEFINE( s, d ) \
83 __asm__ __volatile__ ( "\n->" x )
87 #define DEFINE_UL( s, ul ) \
88 printf( "#define %s\t%lu\n", s, (unsigned long) (ul) );
90 #define DEFINE( s, d ) \
91 printf( "#define %s\t0x%" PRIx64 "\n", s, (uint64_t) d );
95 #define OFFSET( s, t, m ) \
96 DEFINE_UL( s, offsetof( t, m ) )
98 #define SIZEOF( s, t ) \
99 DEFINE_UL( s, sizeof(t) )
103 int main( int argc
, char **argv
)
106 printf( " * This file is automatically generated from the Mesa internal type\n" );
107 printf( " * definitions. Do not edit directly.\n" );
110 printf( "#ifndef __ASM_TYPES_H__\n" );
111 printf( "#define __ASM_TYPES_H__\n" );
115 /* struct gl_context offsets:
117 OFFSET_HEADER( "struct gl_context" );
120 OFFSET( "CTX_LIGHT_ENABLED ", struct gl_context
, Light
.Enabled
);
121 OFFSET( "CTX_LIGHT_SHADE_MODEL ", struct gl_context
, Light
.ShadeModel
);
122 OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", struct gl_context
, Light
.ColorMaterialFace
);
123 OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", struct gl_context
, Light
.ColorMaterialMode
);
124 OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", struct gl_context
, Light
._ColorMaterialBitmask
);
125 OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", struct gl_context
, Light
.ColorMaterialEnabled
);
126 OFFSET( "CTX_LIGHT_ENABLED_LIST ", struct gl_context
, Light
.EnabledList
);
127 OFFSET( "CTX_LIGHT_NEED_VERTS ", struct gl_context
, Light
._NeedVertices
);
128 OFFSET( "CTX_LIGHT_BASE_COLOR ", struct gl_context
, Light
._BaseColor
);
131 /* struct vertex_buffer offsets:
133 OFFSET_HEADER( "struct vertex_buffer" );
135 OFFSET( "VB_SIZE ", struct vertex_buffer
, Size
);
136 OFFSET( "VB_COUNT ", struct vertex_buffer
, Count
);
138 OFFSET( "VB_ELTS ", struct vertex_buffer
, Elts
);
139 OFFSET( "VB_OBJ_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_POS
] );
140 OFFSET( "VB_EYE_PTR ", struct vertex_buffer
, EyePtr
);
141 OFFSET( "VB_CLIP_PTR ", struct vertex_buffer
, ClipPtr
);
142 OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer
, NdcPtr
);
143 OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer
, ClipOrMask
);
144 OFFSET( "VB_CLIP_MASK ", struct vertex_buffer
, ClipMask
);
145 OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_NORMAL
] );
146 OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer
, EdgeFlag
);
147 OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX0
] );
148 OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX1
] );
149 OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX2
] );
150 OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_TEX3
] );
151 OFFSET( "VB_INDEX_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_COLOR_INDEX
] );
152 OFFSET( "VB_COLOR_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_COLOR0
] );
153 OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_COLOR1
] );
154 OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer
, AttribPtr
[_TNL_ATTRIB_FOG
] );
155 OFFSET( "VB_PRIMITIVE ", struct vertex_buffer
, Primitive
);
158 DEFINE_HEADER( "struct vertex_buffer" );
160 /* XXX use new labels here someday after vertex proram is done */
161 DEFINE( "VERT_BIT_OBJ ", VERT_BIT_POS
);
162 DEFINE( "VERT_BIT_NORM ", VERT_BIT_NORMAL
);
163 DEFINE( "VERT_BIT_RGBA ", VERT_BIT_COLOR0
);
164 DEFINE( "VERT_BIT_SPEC_RGB ", VERT_BIT_COLOR1
);
165 DEFINE( "VERT_BIT_FOG_COORD ", VERT_BIT_FOG
);
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
);
172 /* GLvector4f offsets:
174 OFFSET_HEADER( "GLvector4f" );
176 OFFSET( "V4F_DATA ", GLvector4f
, data
);
177 OFFSET( "V4F_START ", GLvector4f
, start
);
178 OFFSET( "V4F_COUNT ", GLvector4f
, count
);
179 OFFSET( "V4F_STRIDE ", GLvector4f
, stride
);
180 OFFSET( "V4F_SIZE ", GLvector4f
, size
);
181 OFFSET( "V4F_FLAGS ", GLvector4f
, flags
);
183 DEFINE_HEADER( "GLvector4f" );
185 DEFINE( "VEC_MALLOC ", VEC_MALLOC
);
186 DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE
);
187 DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE
);
189 DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1
);
190 DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2
);
191 DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3
);
192 DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4
);
197 OFFSET_HEADER( "GLmatrix" );
199 OFFSET( "MATRIX_DATA ", GLmatrix
, m
);
200 OFFSET( "MATRIX_INV ", GLmatrix
, inv
);
201 OFFSET( "MATRIX_FLAGS ", GLmatrix
, flags
);
202 OFFSET( "MATRIX_TYPE ", GLmatrix
, type
);
205 /* struct gl_light offsets:
207 OFFSET_HEADER( "struct gl_light" );
209 OFFSET( "LIGHT_NEXT ", struct gl_light
, next
);
210 OFFSET( "LIGHT_PREV ", struct gl_light
, prev
);
212 OFFSET( "LIGHT_AMBIENT ", struct gl_light
, Ambient
);
213 OFFSET( "LIGHT_DIFFUSE ", struct gl_light
, Diffuse
);
214 OFFSET( "LIGHT_SPECULAR ", struct gl_light
, Specular
);
215 OFFSET( "LIGHT_EYE_POSITION ", struct gl_light
, EyePosition
);
216 OFFSET( "LIGHT_SPOT_DIRECTION ", struct gl_light
, SpotDirection
);
217 OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light
, SpotExponent
);
218 OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light
, SpotCutoff
);
219 OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light
, _CosCutoff
);
220 OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light
, ConstantAttenuation
);
221 OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light
, LinearAttenuation
);
222 OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light
, QuadraticAttenuation
);
223 OFFSET( "LIGHT_ENABLED ", struct gl_light
, Enabled
);
225 OFFSET( "LIGHT_FLAGS ", struct gl_light
, _Flags
);
227 OFFSET( "LIGHT_POSITION ", struct gl_light
, _Position
);
228 OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light
, _VP_inf_norm
);
229 OFFSET( "LIGHT_H_INF_NORM ", struct gl_light
, _h_inf_norm
);
230 OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light
, _NormSpotDirection
);
231 OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light
, _VP_inf_spot_attenuation
);
233 OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light
, _MatAmbient
);
234 OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light
, _MatDiffuse
);
235 OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light
, _MatSpecular
);
237 SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light
);
239 DEFINE_HEADER( "struct gl_light" );
241 DEFINE( "LIGHT_SPOT ", LIGHT_SPOT
);
242 DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER
);
243 DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL
);
245 DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES
);
248 /* struct gl_lightmodel offsets:
250 OFFSET_HEADER( "struct gl_lightmodel" );
252 OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel
, Ambient
);
253 OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel
, LocalViewer
);
254 OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel
, TwoSide
);
255 OFFSET( "LIGHT_MODEL_COLOR_CONTROL ", struct gl_lightmodel
, ColorControl
);
260 printf( "#endif /* __ASM_TYPES_H__ */\n" );