I've been playing with the new ATI linux drivers recently.  It turns
out that they have a performance problem that gets tickled by plib.

Plib allows you to pick wrapped or clamped texture borders when you
create your ssgTexture.  To get the clamping, it uses the original
GL_CLAMP mode, instead of OpenGL 1.2+ GL_CLAMP_TO_EDGE.

The problem is that the original OpenGL texture border behavior, as
specified, isn't implemented by any consumer hardware.  It requires
that the border color (or texture border) be sampled at the edge of
the texture.  Most drivers (at least NVidia's and DRI) actually cheat,
and treat GL_CLAMP as a synonym for GL_CLAMP_TO_EDGE.

Since Plib doesn't provide control over the texture border, existing
plib applications (at least FlightGear) actually *depend* on this
misinterpretation.  Running FlightGear under software Mesa creates
dark lines in the runways where the default black border is sampled
between the tiled textures.

As it happens, ATI complicated things with a 100% correct
implementation of texture wrap modes.  Running under ATI's drivers,
you see lines like this:

  http://www.plausible.org/andy/ati-texture-border.jpg

And it gets worse.  While the drivers support this mode, the hardware
actually does not.  So it's falling back to a slow path and is really
slow.  By default, FlightGear under ATI's drivers is much slower than
under DRI.  Changing plib to use GL_CLAMP_TO_EDGE got almost a 3x
performance boost when there are a large number of runway pixels on
the screen (hardly an uncommon occurrence)

Since this is actually correct behavior per the spec, we can't ask
that they fix it in the drivers (even if it would be nice for them to
mimick everybody else's behavior).  The attached patch causes Plib to
ask for the mode that the hardware supports, at least when compiled
against OpenGL 1.2 or newer.  Really, that's what we want anyway.  The
old 1.0 texture border behavior is problematic and confusing unless
you understand it very well.

Andy

Index: ssgTexture.cxx
===================================================================
RCS file: /cvsroot/plib/plib/src/ssg/ssgTexture.cxx,v
retrieving revision 1.22
diff -u -w -r1.22 ssgTexture.cxx
--- ssgTexture.cxx      2 Sep 2002 06:05:49 -0000       1.22
+++ ssgTexture.cxx      18 Dec 2002 22:53:09 -0000
@@ -58,10 +58,17 @@
   glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR ) ;
   glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER,
                     mipmap ? GL_LINEAR_MIPMAP_LINEAR : GL_LINEAR ) ;
+
+#ifdef GL_VERSION_1_2
+# define PLIB_CLAMP_MODE GL_CLAMP_TO_EDGE
+#else
+# define PLIB_CLAMP_MODE GL_CLAMP
+#endif
+
   glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,
-                    wrapu ? GL_REPEAT : GL_CLAMP ) ;
+                    wrapu ? GL_REPEAT : PLIB_CLAMP_MODE ) ;
   glTexParameteri ( GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,
-                    wrapv ? GL_REPEAT : GL_CLAMP ) ;
+                    wrapv ? GL_REPEAT : PLIB_CLAMP_MODE ) ;

 #ifdef GL_VERSION_1_1
   glBindTexture   ( GL_TEXTURE_2D, 0 ) ;


_______________________________________________
Flightgear-devel mailing list
[EMAIL PROTECTED]
http://mail.flightgear.org/mailman/listinfo/flightgear-devel

Reply via email to