






Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!







In general there are four places a graphics system can become bottlenecked:
Type of Board
Speed to the Board
Speed from the Board
PCI 132 Mb/sec 132 Mb/sec
AGP 8X 2 Gb/sec 264 Mb/sec
PCI Express 4 Gb/sec 4 Gb/sec
Part of the trick is to achieve a balance of the load between these four elements.
glFinish() blocks until the graphics card is finished with what has been sent to it so far. Use it to generate benchmark timing information. Take it out for production. Never, ever, use it in production code.
Understand the nature of your scene against the four places a graphics scene can become bottlenecked.
Benchmark if you are not sure.
Quickly pre-eliminate as much scenery as possible. (There is a dividing line here. If it takes too much computation time to eliminate a section of the scene, it might be better to display it and let the graphics hardware do it.)
Cull based on comparing bounding volumes with the viewing frustum -- try to achieve quick trivial rejections
The bounding volume is out-of-bounds if all 8 points are out-of-bounds for the same reason The Cohen-Sutherland algorithm:
Clip Code
L R
F
N
L R B T N F
32 16 8 4 2 1
Disable lighting, or simulate it in a texture
Use directional lights, not positional
Use quad strips instead of quads – transform less points
Use triangle strips instead of triangles, and instead of quad anythings. (The vendors say this, but I am not sure it is true…)
Better: use vertex arrays – only transform each vertex once
Best: use vertex objects – vertex data gets stored on the graphics card.
Maximize the size of vertex array/object blocks Small batches of geometry can kill performance 100 triangles/batch should be a minimum
= 500 would be better Some game development companies say they try to use a size of 10,000 vertices or more
Use multiple levels of detail, depending on how much of the screen a set of primitives occupies. Use occlusion testing to determine if this is necessary.
Pre-transform objects which are undergoing constant (“static”) transformations. E.g., your vector cloud. (I.e., don’t use a pile of glPushMatrix( ) - glRotatef( ) – glCallList( ) – glPopMatrix( ) calls.)
Pre-compute as much geometry as you can Use display lists (some drivers implement them in host memory, some in graphics card memory)
Let one frame finish drawing while setting up to draw the next one, i.e., don’t use glFinish( ).
How far away is the object from the viewer? If it’s far away, you don’t need to use as much geometric detail to display it. Occlusion querying can help. (Occlusion query lets you pretend-render a bounding box, and the graphics processor will tell you how many pixels it would have occupied.)
Don’t use up your “polygon budget” if you don’t need to
Keep several representations for different components of the scene and switch between them.
Example #1: Different resolutions of GLUT spheres
Example #2: Polygon mesh decimation
Level-of-detailing can also be done as a function of the speed with which an object is moving in the scene.
Reduces polygon count without apparent loss of detail
Textures can be used in Level of Detail analysis
Make “plywood sets” instead of 3D scene detail E.g., a distant forest or mountains
Can bring in full 3D detail as you get closer
Build lighting into the texture image, and then display it as a GL_REPLACE texture
Render 3D scenes into an image and use it as a texture This is referred to as “render-to-texture”. E.g., creating the distant forest or mountains
Use fog to cover up a close-in far clipping plane – fog and haze can hide the fact that you are far-clipping away a lot of scene detail. And you thought it was just part of the game… :-)
Run timing tests by using glFinish() in Display()to completely clear out the pipeline.
glFinish(); int t0 = glutGet( GLUT_ELAPSED_TIME );
<< All Graphics Calls except Swapping the Double Buffers>>
glFinish(); int t1 = glutGet( GLUT_ELAPSED_TIME );
glutSwapBuffers(); fprintf( stderr, "One display frame took %d milliseconds\n", t1 – t0 );
Definitely remove this for production runs !!
Graphics cards today are really fast. Make your test size really big so that the precision of the system clock is not an issue.
Be careful about just putting a for( ) loop around a set of code. Some compilers will optimize that down to just one loop. If the time seems to be independent of the number of loops, fool the compiler by translating the scene based on the loop index.
Benchmarking is worthwhile to do. You sometimes get exactly what you thought you’d get. But, sometimes you get wildly unexpected results, such as this
0
4
8
12
16
20
24
28
32
36
40
44
48
52
56
(^1864) (^2004006009002000409670009000) 1638430000400005500065536 Strip Width
MTri / Sec
Sys AGP
Credit: Daniel New
Be aware that you can now place your own code in the per-vertex and per-fragment parts of the graphics hardware. This can allow you to move operations to the graphics card that used to need to be on the CPU.
This can be used, for example, to:
Application OpenGL Command
Vertex Processing
Rasterizing Fragment Processing
Display
Geometry Processing