-/* $Id: gen_matypes.c,v 1.4 2001/12/16 11:28:20 brianp Exp $ */
-
/*
* Mesa 3-D graphics library
- * Version: 3.5
*
- * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
+ * Copyright (C) 1999-2006 Brian Paul All Rights Reserved.
*
* Permission is hereby granted, free of charge, to any person obtaining a
* copy of this software and associated documentation files (the "Software"),
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
- * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
- * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
- * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR
+ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE,
+ * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR
+ * OTHER DEALINGS IN THE SOFTWARE.
*
* Authors:
- * Gareth Hughes <gareth@valinux.com>
+ * Gareth Hughes
*/
/*
* Mesa, including lighting, clipping, texture image conversion etc.
*/
-#ifdef PC_HEADER
-#include "all.h"
-#else
-#include "glheader.h"
-#include "mtypes.h"
-#include "tnl/t_context.h"
+#ifndef __STDC_FORMAT_MACROS
+#define __STDC_FORMAT_MACROS
#endif
+#include <stdio.h>
+#include <inttypes.h>
+
+#include "main/glheader.h"
+#include "main/mtypes.h"
+#include "tnl/t_context.h"
+
+
#undef offsetof
#define offsetof( type, member ) ((size_t) &((type *)0)->member)
printf( "\n" ); \
printf( "/* =====================================================" \
"========\n" ); \
- printf( " * Offsets for %s\n", x ); \
+ printf( " * Offsets for " x "\n" ); \
printf( " */\n" ); \
printf( "\n" ); \
} while (0)
do { \
printf( "\n" ); \
printf( "/*\n" ); \
- printf( " * Flags for %s\n", x ); \
+ printf( " * Flags for " x "\n" ); \
printf( " */\n" ); \
printf( "\n" ); \
} while (0)
-#define OFFSET( s, t, m ) \
- printf( "#define %s\t%d\n", s, offsetof( t, m ) );
+#ifdef ASM_OFFSETS
-#define SIZEOF( s, t ) \
- printf( "#define %s\t%d\n", s, sizeof(t) );
+/*
+ * Format the asm output in a special way that we can manipulate
+ * after the fact and turn into the final header for the target.
+ */
+
+#define DEFINE_UL( s, ul ) \
+ __asm__ __volatile__ ( "\n->" s " %0" : : "i" (ul) )
#define DEFINE( s, d ) \
- printf( "#define %s\t0x%x\n", s, d );
+ DEFINE_UL( s, d )
+
+#define printf( x ) \
+ __asm__ __volatile__ ( "\n->" x )
+
+#else
+
+#define DEFINE_UL( s, ul ) \
+ printf( "#define %s\t%lu\n", s, (unsigned long) (ul) );
+
+#define DEFINE( s, d ) \
+ printf( "#define %s\t0x%" PRIx64 "\n", s, (uint64_t) d );
+
+#endif
+
+#define OFFSET( s, t, m ) \
+ DEFINE_UL( s, offsetof( t, m ) )
+
+#define SIZEOF( s, t ) \
+ DEFINE_UL( s, sizeof(t) )
printf( "#ifndef __ASM_TYPES_H__\n" );
printf( "#define __ASM_TYPES_H__\n" );
printf( "\n" );
- printf( "#include \"assyntax.h\"\n" );
- /* GLcontext offsets:
+ /* struct gl_context offsets:
*/
- OFFSET_HEADER( "GLcontext" );
+ OFFSET_HEADER( "struct gl_context" );
- OFFSET( "CTX_DRIVER_CTX ", GLcontext, DriverCtx );
printf( "\n" );
- OFFSET( "CTX_LIGHT_ENABLED ", GLcontext, Light.Enabled );
- OFFSET( "CTX_LIGHT_SHADE_MODEL ", GLcontext, Light.ShadeModel );
- OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", GLcontext, Light.ColorMaterialFace );
- OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", GLcontext, Light.ColorMaterialMode );
- OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", GLcontext, Light.ColorMaterialBitmask );
- OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", GLcontext, Light.ColorMaterialEnabled );
- OFFSET( "CTX_LIGHT_ENABLED_LIST ", GLcontext, Light.EnabledList );
- OFFSET( "CTX_LIGHT_NEED_VERTS ", GLcontext, Light._NeedVertices );
- OFFSET( "CTX_LIGHT_FLAGS ", GLcontext, Light._Flags );
- OFFSET( "CTX_LIGHT_BASE_COLOR ", GLcontext, Light._BaseColor );
+ OFFSET( "CTX_LIGHT_ENABLED ", struct gl_context, Light.Enabled );
+ OFFSET( "CTX_LIGHT_SHADE_MODEL ", struct gl_context, Light.ShadeModel );
+ OFFSET( "CTX_LIGHT_COLOR_MAT_FACE ", struct gl_context, Light.ColorMaterialFace );
+ OFFSET( "CTX_LIGHT_COLOR_MAT_MODE ", struct gl_context, Light.ColorMaterialMode );
+ OFFSET( "CTX_LIGHT_COLOR_MAT_MASK ", struct gl_context, Light._ColorMaterialBitmask );
+ OFFSET( "CTX_LIGHT_COLOR_MAT_ENABLED ", struct gl_context, Light.ColorMaterialEnabled );
+ OFFSET( "CTX_LIGHT_ENABLED_LIGHTS ", struct gl_context, Light._EnabledLights );
+ OFFSET( "CTX_LIGHT_NEED_VERTS ", struct gl_context, Light._NeedVertices );
+ OFFSET( "CTX_LIGHT_BASE_COLOR ", struct gl_context, Light._BaseColor );
/* struct vertex_buffer offsets:
OFFSET( "VB_SIZE ", struct vertex_buffer, Size );
OFFSET( "VB_COUNT ", struct vertex_buffer, Count );
printf( "\n" );
- OFFSET( "VB_FIRST_CLIPPED ", struct vertex_buffer, FirstClipped );
- OFFSET( "VB_FIRST_PRIMITIVE ", struct vertex_buffer, FirstPrimitive );
- printf( "\n" );
OFFSET( "VB_ELTS ", struct vertex_buffer, Elts );
- OFFSET( "VB_OBJ_PTR ", struct vertex_buffer, ObjPtr );
+ OFFSET( "VB_OBJ_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_POS] );
OFFSET( "VB_EYE_PTR ", struct vertex_buffer, EyePtr );
OFFSET( "VB_CLIP_PTR ", struct vertex_buffer, ClipPtr );
- OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer, ProjectedClipPtr );
+ OFFSET( "VB_PROJ_CLIP_PTR ", struct vertex_buffer, NdcPtr );
OFFSET( "VB_CLIP_OR_MASK ", struct vertex_buffer, ClipOrMask );
OFFSET( "VB_CLIP_MASK ", struct vertex_buffer, ClipMask );
- OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer, NormalPtr );
+ OFFSET( "VB_NORMAL_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_NORMAL] );
OFFSET( "VB_EDGE_FLAG ", struct vertex_buffer, EdgeFlag );
- OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer, TexCoordPtr[0] );
- OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer, TexCoordPtr[1] );
- OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer, TexCoordPtr[2] );
- OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer, TexCoordPtr[3] );
- OFFSET( "VB_INDEX_PTR ", struct vertex_buffer, IndexPtr );
- OFFSET( "VB_COLOR_PTR ", struct vertex_buffer, ColorPtr );
- OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer, SecondaryColorPtr );
- OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer, FogCoordPtr );
- OFFSET( "VB_POINT_SIZE_PTR ", struct vertex_buffer, PointSizePtr );
- OFFSET( "VB_MATERIAL ", struct vertex_buffer, Material );
- OFFSET( "VB_MATERIAL_MASK ", struct vertex_buffer, MaterialMask );
- OFFSET( "VB_FLAG ", struct vertex_buffer, Flag );
+ OFFSET( "VB_TEX0_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX0] );
+ OFFSET( "VB_TEX1_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX1] );
+ OFFSET( "VB_TEX2_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX2] );
+ OFFSET( "VB_TEX3_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_TEX3] );
+ OFFSET( "VB_INDEX_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR_INDEX] );
+ OFFSET( "VB_COLOR_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR0] );
+ OFFSET( "VB_SECONDARY_COLOR_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_COLOR1] );
+ OFFSET( "VB_FOG_COORD_PTR ", struct vertex_buffer, AttribPtr[_TNL_ATTRIB_FOG] );
OFFSET( "VB_PRIMITIVE ", struct vertex_buffer, Primitive );
- OFFSET( "VB_PRIMITIVE_LENGTH ", struct vertex_buffer, PrimitiveLength );
- printf( "\n" );
- OFFSET( "VB_IMPORTABLE_DATA ", struct vertex_buffer, importable_data );
printf( "\n" );
- OFFSET( "VB_LAST_CLIPPED ", struct vertex_buffer, LastClipped );
DEFINE_HEADER( "struct vertex_buffer" );
/* XXX use new labels here someday after vertex proram is done */
- DEFINE( "VERT_OBJ ", VERT_OBJ_BIT );
- DEFINE( "VERT_NORM ", VERT_NORMAL_BIT );
- DEFINE( "VERT_RGBA ", VERT_COLOR0_BIT );
- DEFINE( "VERT_SPEC_RGB ", VERT_COLOR1_BIT );
- DEFINE( "VERT_FOG_COORD ", VERT_FOG_BIT );
- DEFINE( "VERT_INDEX ", VERT_INDEX_BIT );
- DEFINE( "VERT_EDGE ", VERT_EDGEFLAG_BIT );
- DEFINE( "VERT_TEX0 ", VERT_TEX0_BIT );
- DEFINE( "VERT_TEX1 ", VERT_TEX1_BIT );
- DEFINE( "VERT_TEX2 ", VERT_TEX2_BIT );
- DEFINE( "VERT_TEX3 ", VERT_TEX3_BIT );
- DEFINE( "VERT_EVAL_C1 ", VERT_EVAL_C1 );
- DEFINE( "VERT_EVAL_C2 ", VERT_EVAL_C2 );
- DEFINE( "VERT_EVAL_P1 ", VERT_EVAL_P1 );
- DEFINE( "VERT_EVAL_P2 ", VERT_EVAL_P2 );
- DEFINE( "VERT_OBJ_3 ", VERT_OBJ_3 );
- DEFINE( "VERT_OBJ_4 ", VERT_OBJ_4 );
- DEFINE( "VERT_MATERIAL ", VERT_MATERIAL );
- DEFINE( "VERT_ELT ", VERT_ELT );
- DEFINE( "VERT_BEGIN ", VERT_BEGIN );
- DEFINE( "VERT_END ", VERT_END );
- DEFINE( "VERT_END_VB ", VERT_END_VB );
- DEFINE( "VERT_POINT_SIZE ", VERT_POINT_SIZE );
- DEFINE( "VERT_EYE ", VERT_EYE );
- DEFINE( "VERT_CLIP ", VERT_CLIP );
- printf( "\n" );
- DEFINE( "VERT_OBJ_23 ", VERT_OBJ_3 );
- DEFINE( "VERT_OBJ_234 ", VERT_OBJ_4 );
-
-
- /* GLvector3f offsets:
- */
- OFFSET_HEADER( "GLvector3f" );
-
- OFFSET( "V3F_DATA ", GLvector3f, data );
- OFFSET( "V3F_START ", GLvector3f, start );
- OFFSET( "V3F_COUNT ", GLvector3f, count );
- OFFSET( "V3F_STRIDE ", GLvector3f, stride );
- OFFSET( "V3F_FLAGS ", GLvector3f, flags );
+ DEFINE( "VERT_BIT_OBJ ", VERT_BIT_POS );
+ DEFINE( "VERT_BIT_NORM ", VERT_BIT_NORMAL );
+ DEFINE( "VERT_BIT_RGBA ", VERT_BIT_COLOR0 );
+ DEFINE( "VERT_BIT_SPEC_RGB ", VERT_BIT_COLOR1 );
+ DEFINE( "VERT_BIT_FOG_COORD ", VERT_BIT_FOG );
+ DEFINE( "VERT_BIT_TEX0 ", VERT_BIT_TEX0 );
+ DEFINE( "VERT_BIT_TEX1 ", VERT_BIT_TEX1 );
+ DEFINE( "VERT_BIT_TEX2 ", VERT_BIT_TEX2 );
+ DEFINE( "VERT_BIT_TEX3 ", VERT_BIT_TEX3 );
/* GLvector4f offsets:
*/
OFFSET_HEADER( "struct gl_light" );
- OFFSET( "LIGHT_NEXT ", struct gl_light, next );
- OFFSET( "LIGHT_PREV ", struct gl_light, prev );
printf( "\n" );
OFFSET( "LIGHT_AMBIENT ", struct gl_light, Ambient );
OFFSET( "LIGHT_DIFFUSE ", struct gl_light, Diffuse );
OFFSET( "LIGHT_SPECULAR ", struct gl_light, Specular );
OFFSET( "LIGHT_EYE_POSITION ", struct gl_light, EyePosition );
- OFFSET( "LIGHT_EYE_DIRECTION ", struct gl_light, EyeDirection );
+ OFFSET( "LIGHT_SPOT_DIRECTION ", struct gl_light, SpotDirection );
OFFSET( "LIGHT_SPOT_EXPONENT ", struct gl_light, SpotExponent );
OFFSET( "LIGHT_SPOT_CUTOFF ", struct gl_light, SpotCutoff );
OFFSET( "LIGHT_COS_CUTOFF ", struct gl_light, _CosCutoff );
OFFSET( "LIGHT_POSITION ", struct gl_light, _Position );
OFFSET( "LIGHT_VP_INF_NORM ", struct gl_light, _VP_inf_norm );
OFFSET( "LIGHT_H_INF_NORM ", struct gl_light, _h_inf_norm );
- OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light, _NormDirection );
+ OFFSET( "LIGHT_NORM_DIRECTION ", struct gl_light, _NormSpotDirection );
OFFSET( "LIGHT_VP_INF_SPOT_ATTEN ", struct gl_light, _VP_inf_spot_attenuation );
printf( "\n" );
- OFFSET( "LIGHT_SPOT_EXP_TABLE ", struct gl_light, _SpotExpTable );
OFFSET( "LIGHT_MAT_AMBIENT ", struct gl_light, _MatAmbient );
OFFSET( "LIGHT_MAT_DIFFUSE ", struct gl_light, _MatDiffuse );
OFFSET( "LIGHT_MAT_SPECULAR ", struct gl_light, _MatSpecular );