OpenGL vs. Java state buffering

Started by dronus, October 26, 2005, 08:05:22

Previous topic - Next topic

dronus

While working on a growing complex thing, i'm in question if it would be usefull to hold gl's state local rather than in OpenGL only.
It is stated by OpenGL specs that many state changes are instantly done without checking for neccesserity involving maybe costly functions.

So even if i try to ceap my states clean, often a glPushAttrib is more convinient, and maybe i set states even if they are already set. As LWJGL is a kind of bottleneck making gl calls more costly as they woul be in c, is seems useful to cache the state on Java-side, only telling the real changes to gl, and maybe even replace glPush/PopAttrib by single state setters, if only a few values are modified.

Somebody any experience/opinion to that? As this seems quite complicated, i dont like to implement only to see there is no factual performance gain...

thanks
Paul

princec

We would like to keep the LWJGL a pure binding with the minimum of bells and whistles, and allow others to build this kind of thing on top as they see fit.

Cas :)

Fool Running

I think he's asking if there would be a performace benifit for him to do it in his project as he is setting the OpenGL state without checking it beforehand.
Unfortunatly, I don't know the answer  :lol:
EDIT: my guess would be it would be a benifit since JNI is expensive.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D

spasi

Besides the JNI overhead (which is not that important), it is ALWAYS a good idea to cache GL state and only change what needs to be changed. Keep in mind that the cost of an unnecessary state change may be far greater than a simple JNI call.

dronus

hmm yeah.. "maybe far greater".. but maybe not? if gl is as optimized one might think, the most state changes would maybe actually be reflected in a new saved state and nothing else.. until some operation evaluates it.

maybe i should go for a test ride.

thanks
Paul


EDIT: ps.. cas..   fool runing was right... hey you fell your "baby" attacked quite fast, huh? :-)    so i state:
"yes, i confess to know lwjgl is just a most simple wrapper to opengl" and beeing a hardcore specs freak: thats just the way it should.  *g*