Rob Jenkins (robj++at++quid)
Mon, 18 Nov 1996 08:33:18 -0800
Below are some general OpenGL tips from an internal web page by Robert Keller,
maybe others will chip in with more:
--------------------------------------------------------------------------
Performance Tips
Collected Wisdom for Making Apps Fast
Minimize the amount of data sent to the pipe
Use display lists to cache static geometry
Use texture memory or offscreen framebuffer memory to cache pixels
Use small aligned data types for immediate mode drawing (e.g. 32-bit
int for RGBA, surface normals packed into three shorts, texture
coords packed into two shorts)
Use the packed vertex array extension
Never use more than one thread to draw to a pipe
Use multiple OpenGL rendering contexts sparingly
KONA will handle about 60K context changes per second, so each
glXMakeCurrent() call costs about 100 textured triangles or 800 32-bit
pixels
Texture memory management tips
Use texture objects rather than textures in dlists
OpenGL will make copies of textures for context switching, so
deallocate your own copies after loading them
To load a texture immediately: enable texturing, bind your texture,
and call glTexImage*()
To load a texture only when it's referenced: disable texturing, bind
your texture, and call glTexImage*(). A copy will be made!
Don't overcommit texture memory
Use subtexture loading to implement your own texture memory management
policy. For example, allocate one large empty texture, use
glTexSubimage*() to load it piecewise, and use the
texture matrix to select the relevant portion.
Avoid OpenGL texture borders. Use the border style
GL_CLAMP_TO_EDGE_SGIS instead. It's like IrisGL
clamping on RealityEngine.
Use 16-bit texels whenever possible; RGBA4 can be twice as fast as RGBA8
To optimize the color palette for 16-bit texels, use a texture lookup
table and texture scale/bias
Subtextures should be multiples of 8 texels wide
When loading a texture, use a pixel format that matches the texel format
exactly
Offscreen rendering tools:
pbuffers are pixel arrays that behave much like windows, except
they're not visible fbconfigs define color buffer depths, presence of
Z buffer, etc. glXMakeCurrentReadSGI() allows you to read from one
window or pbuffer while writing to another glCopyTexImage*()
allows you to copy from window or pbuffer to texture memory
Offscreen rendering tips:
pbuffers compete with windows for space in the framebuffer
pbuffers are swappable, but not virtualized; the total amount of space
allocated to pbuffers can't exceed the size of the framebuffer
Nonvolatile (swappable) pbuffers are easier to use, but can cause
thrashing; we recommend using volatile pbuffers and treating
them just like windows (e.g. repaint them when you receive an expose
event).
As a general rule, it's more efficient to change state information when
the associated function is disabled than when it's enabled. For example,
``glEnable(GL_LINE_SMOOTH); glLineWidth(width);'' causes the line
antialiasing table to be computed twice.
For best results, the near clipping plane should map to 0.0 and the far
clipping plane to 1.0. (This is the default.)
When using a Visual with a 1-bit stencil, it's faster to clear both the
depth buffer and the stencil buffer than it is to clear the depth
buffer alone
Use the color matrix extension for swapping and smearing color channels.
The implementation is optimized for cases in which the matrix is
composed of zeros and ones.
Be sure to check for the usual things - indirect contexts, drawing images
with depth buffering enabled, etc.
---------------------------------------------------------------------
--
________________________________________________________________
Rob Jenkins mailto:robj++at++csd.sgi.com
Silicon Graphics, Mtn View, California, USA
=======================================================================
List Archives, FAQ, FTP: http://www.sgi.com/Technology/Performer/
Submissions: info-performer++at++sgi.com
Admin. requests: info-performer-request++at++sgi.com
This archive was generated by hypermail 2.0b2 on Mon Aug 10 1998 - 17:53:58 PDT