[MSHTML_WINETEST]
[reactos.git] / reactos / dll / opengl / mesa / src / mesa / x86 / gen_matypes.c
1 /*
2 * Mesa 3-D graphics library
3 * Version: 6.5.1
4 *
5 * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
6 *
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:
13 *
14 * The above copyright notice and this permission notice shall be included
15 * in all copies or substantial portions of the Software.
16 *
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.
23 *
24 * Authors:
25 * Gareth Hughes
26 */
27
28 /*
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.
33 */
34
35 #ifndef __STDC_FORMAT_MACROS
36 #define __STDC_FORMAT_MACROS
37 #endif
38 #include <inttypes.h>
39
40 #include "main/glheader.h"
41 #include "main/mtypes.h"
42 #include "tnl/t_context.h"
43
44
45 #undef offsetof
46 #define offsetof( type, member ) ((size_t) &((type *)0)->member)
47
48
49 #define OFFSET_HEADER( x ) \
50 do { \
51 printf( "\n" ); \
52 printf( "\n" ); \
53 printf( "/* =====================================================" \
54 "========\n" ); \
55 printf( " * Offsets for %s\n", x ); \
56 printf( " */\n" ); \
57 printf( "\n" ); \
58 } while (0)
59
60 #define DEFINE_HEADER( x ) \
61 do { \
62 printf( "\n" ); \
63 printf( "/*\n" ); \
64 printf( " * Flags for %s\n", x ); \
65 printf( " */\n" ); \
66 printf( "\n" ); \
67 } while (0)
68
69 #define OFFSET( s, t, m ) \
70 printf( "#define %s\t%lu\n", s, (unsigned long) offsetof( t, m ) );
71
72 #define SIZEOF( s, t ) \
73 printf( "#define %s\t%lu\n", s, (unsigned long) sizeof(t) );
74
75 #define DEFINE( s, d ) \
76 printf( "#define %s\t0x%" PRIx64 "\n", s, (uint64_t) d );
77
78
79
80 int main( int argc, char **argv )
81 {
82 printf( "/*\n" );
83 printf( " * This file is automatically generated from the Mesa internal type\n" );
84 printf( " * definitions. Do not edit directly.\n" );
85 printf( " */\n" );
86 printf( "\n" );
87 printf( "#ifndef __ASM_TYPES_H__\n" );
88 printf( "#define __ASM_TYPES_H__\n" );
89 printf( "\n" );
90
91
92 /* struct gl_context offsets:
93 */
94 OFFSET_HEADER( "struct gl_context" );
95
96 OFFSET( "CTX_DRIVER_CTX ", struct gl_context, DriverCtx );
97 printf( "\n" );
98 OFFSET( "CTX_LIGHT_ENABLED ", struct gl_context, Light.Enabled );
99 OFFSET( "CTX_LIGHT_SHADE_MODEL ", struct gl_context, Light.ShadeModel );
100 OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", struct gl_context, Light.ColorMaterialFace );
101 OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", struct gl_context, Light.ColorMaterialMode );
102 OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", struct gl_context, Light.ColorMaterialBitmask );
103 OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", struct gl_context, Light.ColorMaterialEnabled );
104 OFFSET( "CTX_LIGHT_ENABLED_LIST ", struct gl_context, Light.EnabledList );
105 OFFSET( "CTX_LIGHT_NEED_VERTS ", struct gl_context, Light._NeedVertices );
106 OFFSET( "CTX_LIGHT_FLAGS ", struct gl_context, Light._Flags );
107 OFFSET( "CTX_LIGHT_BASE_COLOR ", struct gl_context, Light._BaseColor );
108
109
110 /* struct vertex_buffer offsets:
111 */
112 OFFSET_HEADER( "struct vertex_buffer" );
113
114 OFFSET( "VB_SIZE ", struct vertex_buffer, Size );
115 OFFSET( "VB_COUNT ", struct vertex_buffer, Count );
116 printf( "\n" );
117 OFFSET( "VB_ELTS ", struct vertex_buffer, Elts );
118 OFFSET( "VB_OBJ_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_POS] );
119 OFFSET( "VB_EYE_PTR ", struct vertex_buffer, EyePtr );
120 OFFSET( "VB_CLIP_PTR ", struct vertex_buffer, ClipPtr );
121 OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer, NdcPtr );
122 OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer, ClipOrMask );
123 OFFSET( "VB_CLIP_MASK ", struct vertex_buffer, ClipMask );
124 OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_NORMAL] );
125 OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer, EdgeFlag );
126 OFFSET( "VB_TEX_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX] );
127 OFFSET( "VB_INDEX_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR_INDEX] );
128 OFFSET( "VB_COLOR_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR0] );
129 OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR1] );
130 OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_FOG] );
131 OFFSET( "VB_PRIMITIVE ", struct vertex_buffer, Primitive );
132 printf( "\n" );
133
134 DEFINE_HEADER( "struct vertex_buffer" );
135
136 /* XXX use new labels here someday after vertex proram is done */
137 DEFINE( "VERT_BIT_OBJ ", VERT_BIT_POS );
138 DEFINE( "VERT_BIT_NORM ", VERT_BIT_NORMAL );
139 DEFINE( "VERT_BIT_RGBA ", VERT_BIT_COLOR0 );
140 DEFINE( "VERT_BIT_SPEC_RGB ", VERT_BIT_COLOR1 );
141 DEFINE( "VERT_BIT_FOG_COORD ", VERT_BIT_FOG );
142 DEFINE( "VERT_BIT_TEX0 ", VERT_BIT_TEX0 );
143 DEFINE( "VERT_BIT_TEX1 ", VERT_BIT_TEX1 );
144 DEFINE( "VERT_BIT_TEX2 ", VERT_BIT_TEX2 );
145 DEFINE( "VERT_BIT_TEX3 ", VERT_BIT_TEX3 );
146
147
148 /* GLvector4f offsets:
149 */
150 OFFSET_HEADER( "GLvector4f" );
151
152 OFFSET( "V4F_DATA ", GLvector4f, data );
153 OFFSET( "V4F_START ", GLvector4f, start );
154 OFFSET( "V4F_COUNT ", GLvector4f, count );
155 OFFSET( "V4F_STRIDE ", GLvector4f, stride );
156 OFFSET( "V4F_SIZE ", GLvector4f, size );
157 OFFSET( "V4F_FLAGS ", GLvector4f, flags );
158
159 DEFINE_HEADER( "GLvector4f" );
160
161 DEFINE( "VEC_MALLOC ", VEC_MALLOC );
162 DEFINE( "VEC_NOT_WRITEABLE ", VEC_NOT_WRITEABLE );
163 DEFINE( "VEC_BAD_STRIDE ", VEC_BAD_STRIDE );
164 printf( "\n" );
165 DEFINE( "VEC_SIZE_1 ", VEC_SIZE_1 );
166 DEFINE( "VEC_SIZE_2 ", VEC_SIZE_2 );
167 DEFINE( "VEC_SIZE_3 ", VEC_SIZE_3 );
168 DEFINE( "VEC_SIZE_4 ", VEC_SIZE_4 );
169
170
171 /* GLmatrix offsets:
172 */
173 OFFSET_HEADER( "GLmatrix" );
174
175 OFFSET( "MATRIX_DATA ", GLmatrix, m );
176 OFFSET( "MATRIX_INV ", GLmatrix, inv );
177 OFFSET( "MATRIX_FLAGS ", GLmatrix, flags );
178 OFFSET( "MATRIX_TYPE ", GLmatrix, type );
179
180
181 /* struct gl_light offsets:
182 */
183 OFFSET_HEADER( "struct gl_light" );
184
185 OFFSET( "LIGHT_NEXT ", struct gl_light, next );
186 OFFSET( "LIGHT_PREV ", struct gl_light, prev );
187 printf( "\n" );
188 OFFSET( "LIGHT_AMBIENT ", struct gl_light, Ambient );
189 OFFSET( "LIGHT_DIFFUSE ", struct gl_light, Diffuse );
190 OFFSET( "LIGHT_SPECULAR ", struct gl_light, Specular );
191 OFFSET( "LIGHT_EYE_POSITION ", struct gl_light, EyePosition );
192 OFFSET( "LIGHT_SPOT_DIRECTION ", struct gl_light, SpotDirection );
193 OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light, SpotExponent );
194 OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light, SpotCutoff );
195 OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light, _CosCutoff );
196 OFFSET( "LIGHT_CONST_ATTEN ", struct gl_light, ConstantAttenuation );
197 OFFSET( "LIGHT_LINEAR_ATTEN ", struct gl_light, LinearAttenuation );
198 OFFSET( "LIGHT_QUADRATIC_ATTEN ", struct gl_light, QuadraticAttenuation );
199 OFFSET( "LIGHT_ENABLED ", struct gl_light, Enabled );
200 printf( "\n" );
201 OFFSET( "LIGHT_FLAGS ", struct gl_light, _Flags );
202 printf( "\n" );
203 OFFSET( "LIGHT_POSITION ", struct gl_light, _Position );
204 OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light, _VP_inf_norm );
205 OFFSET( "LIGHT_H_INF_NORM ", struct gl_light, _h_inf_norm );
206 OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light, _NormSpotDirection );
207 OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light, _VP_inf_spot_attenuation );
208 printf( "\n" );
209 OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light, _SpotExpTable );
210 OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light, _MatAmbient );
211 OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light, _MatDiffuse );
212 OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light, _MatSpecular );
213 printf( "\n" );
214 SIZEOF( "SIZEOF_GL_LIGHT ", struct gl_light );
215
216 DEFINE_HEADER( "struct gl_light" );
217
218 DEFINE( "LIGHT_SPOT ", LIGHT_SPOT );
219 DEFINE( "LIGHT_LOCAL_VIEWER ", LIGHT_LOCAL_VIEWER );
220 DEFINE( "LIGHT_POSITIONAL ", LIGHT_POSITIONAL );
221 printf( "\n" );
222 DEFINE( "LIGHT_NEED_VERTICES ", LIGHT_NEED_VERTICES );
223
224
225 /* struct gl_lightmodel offsets:
226 */
227 OFFSET_HEADER( "struct gl_lightmodel" );
228
229 OFFSET( "LIGHT_MODEL_AMBIENT ", struct gl_lightmodel, Ambient );
230 OFFSET( "LIGHT_MODEL_LOCAL_VIEWER ", struct gl_lightmodel, LocalViewer );
231 OFFSET( "LIGHT_MODEL_TWO_SIDE ", struct gl_lightmodel, TwoSide );
232 OFFSET( "LIGHT_MODEL_COLOR_CONTROL ", struct gl_lightmodel, ColorControl );
233
234
235 printf( "\n" );
236 printf( "\n" );
237 printf( "#endif /* __ASM_TYPES_H__ */\n" );
238
239 return 0;
240 }