[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: On state and sorting.



"Adam D. Moss" wrote:

> Basically, OpenGL state changes are expensive.
> Everyone knows this, and I know this, but until I
> really sat down and did some tweak-measure cycles
> I didn't realize /how/ expensive.  In Mesa (probably
> other implementations also), even *redundant* changes
> are very expensive, like binding the same texture twice
> in a row or glEnable()ing GL_TEXTURE_2D when it's
> already enabled.  Ugh.

Yes - it's frighteningly bad.
 
> I'd assumed that texture state changes were expensive
> mostly because of texture-memory-thrashing issues,

Well, that impacts pixel fill performance mostly.

> but, uh, no.  I suppose that since Mesa itself isn't
> spotting redundant changes, they get all the way
> down to the hardware and require a flush of the
> rendering pipeline.  Ugh ugh.

It's a hard call for an OpenGL implementor.  If he
checks for redundant state changes then programs that
are careful to avoid them actually run more slowly.

Since they are generally fighting to get another 0.01
frames per second out of Quake (which *DOES* sort by
state and avoids redundant state changes) the usual decision
is to save time for "well written" programs and let the
rest of us suffer.

----------------------------- Steve Baker -------------------------------
Mail : <sjbaker1@airmail.net>   WorkMail: <sjbaker@link.com>
URLs : http://www.sjbaker.org
       http://plib.sf.net http://tuxaqfh.sf.net http://tuxkart.sf.net
       http://prettypoly.sf.net http://freeglut.sf.net
       http://toobular.sf.net   http://lodestone.sf.net