2 * (C) Copyright IBM Corporation 2002
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * on the rights to use, copy, modify, merge, publish, distribute, sub
9 * license, and/or sell copies of the Software, and to permit persons to whom
10 * the Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice and this permission notice (including the next
13 * paragraph) shall be included in all copies or substantial portions of the
16 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
17 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
18 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
19 * VA LINUX SYSTEM, IBM AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
20 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
21 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
22 * USE OR OTHER DEALINGS IN THE SOFTWARE.
27 * Simple test to measure the overhead of making GL calls.
29 * The main purpose of this test is to measure the difference in calling
30 * overhead of different dispatch methods. Since it uses asm/timex.h to
31 * access the Pentium's cycle counters, it will probably only compile on
32 * Linux (though most architectures have a get_cycles function in timex.h).
33 * That is why it isn't in the default Makefile.
35 * \author Ian Romanick <idr@us.ibm.com>
40 #define GL_GLEXT_PROTOTYPES
45 #define inline __inline__
46 #include <asm/timex.h>
48 static float Width
= 400;
49 static float Height
= 400;
50 static unsigned count
= 1000000;
53 static void Idle( void )
58 #define DO_FUNC(f,p) \
61 for ( i = 0 ; i < count ; i++ ) { \
65 printf("%u calls to % 20s required %llu cycles.\n", count, # f, t1 - t0); \
69 * Main display function. This is the place to add more API calls.
71 static void Display( void )
74 const float v
[3] = { 1.0, 0.0, 0.0 };
78 glBegin(GL_TRIANGLE_STRIP
);
80 DO_FUNC( glColor3fv
, (v
) );
81 DO_FUNC( glNormal3fv
, (v
) );
82 DO_FUNC( glTexCoord2fv
, (v
) );
83 DO_FUNC( glTexCoord3fv
, (v
) );
84 DO_FUNC( glMultiTexCoord2fv
, (GL_TEXTURE0
, v
) );
85 DO_FUNC( glMultiTexCoord2f
, (GL_TEXTURE0
, 0.0, 0.0) );
86 DO_FUNC( glFogCoordfvEXT
, (v
) );
87 DO_FUNC( glFogCoordfEXT
, (0.5) );
95 static void Reshape( int width
, int height
)
99 glViewport( 0, 0, width
, height
);
100 glMatrixMode( GL_PROJECTION
);
102 glOrtho(0.0, width
, 0.0, height
, -1.0, 1.0);
103 glMatrixMode( GL_MODELVIEW
);
108 static void Key( unsigned char key
, int x
, int y
)
121 int main( int argc
, char *argv
[] )
123 glutInit( &argc
, argv
);
124 glutInitWindowSize( (int) Width
, (int) Height
);
125 glutInitWindowPosition( 0, 0 );
127 glutInitDisplayMode( GLUT_RGB
);
129 glutCreateWindow( argv
[0] );
132 count
= strtoul( argv
[1], NULL
, 0 );
134 fprintf( stderr
, "Usage: %s [iterations]\n", argv
[0] );
139 glutReshapeFunc( Reshape
);
140 glutKeyboardFunc( Key
);
141 glutDisplayFunc( Display
);
142 glutIdleFunc( Idle
);