Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

sinistrx

Speed Optimization

This topic is 6494 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Ok I''ve tried all the tricks in the book for speed optimization (keeping math down to simple math like +-*/ by using lookup tables, good state mgmt, calllists, etc.) is there any surefire way to speed up your programs? I have about 3 or 4 objects in my scene as it stands and it''s going way to slow. I can post the code it''s very very beta though.

Share this post


Link to post
Share on other sites
Advertisement
Guest Anonymous Poster
Hmm... not much I can suggest other than to look at the methods you''re using: are they the best methods, could you be doing it with less operations? You could also have a look at www.intel.com -- they have a thing that lets you check where your processing power is going, then concentrate on bumming the parts of the program which consume the most speed.

Share this post


Link to post
Share on other sites
You must avoid states changes.

Search the OpenGL website or SGI one to see what you should do.

Basically load a texture and compute every object using this texture. Texture change has the heavier cost.

Theen, MAterial change are costy, so group by Material too.

Look for other optimisations tricks on the web sites mentionned before.

Good luck.

-* So many things to do, so little time to spend. *-

Share this post


Link to post
Share on other sites
the first + most important rule of game programming
Premature optimization is the root of all evil" (Donald Knuth).

u are aware that
"keeping math down to simple math like +-*/ by using lookup tables" can sometime actually slow down a program

http://members.xoom.com/myBollux

Share this post


Link to post
Share on other sites
What you could do is render at every time and calculate physics and stuff one out of 5 ...
You will increase framerate and Physics not loose too much ...

Or untesselate your objects

Share this post


Link to post
Share on other sites
Write it all in PC Assembly language and link directly with the OpenGL source code. Oh and if you do this let me know because you''ll be busy for a while but you will be the MAN!

Share this post


Link to post
Share on other sites
I''m not sure if that helps, but if you use Visual C++ and run your programs in debug build, try building it for release and run it. Debug builds are very good at finding errors but they can make a program pretty slow.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
My suggestion is to get rid of as many if statements as you can in any inner loops you have. If necessary perform a bunch of arithmetic and logical operations on your variables if this will do it... For instance if you know var is either 0 or 1 the following code is better than an if statement in general;

newvalue = var * value1 + (1 - var) * value2;
is faster in general
if(var)
newvalue = value1;
else
newvalue = value2;

Of course... only start optimizing when its necessary.. as a previous poster stated premature optimization is the root of all evil. And optimizations like the above tend to confuse people for an unnecessary gain in performance. The above method can work wonders though where it works... I was writing a driver this summer and was able to double performance by removing 2 if statements in my inner-most loop. It was an easy situation to optimize ... I knew 99% of the cpu time was in 20 lines of code... but still a wonderful improvement.

Oh... and lookup tables aren''t as good as they once were since modern computers have relatively slow access to main memory. Think about it... a 500 Mhz CPU... 100 Mhz RAM. 5 CPU cycles per memory cycle. About 4 memory cycles to read a datum in memory = 20 CPU cycles just to get a value. Cache helps this problem... but if your lookup table is bigger than your cache you''ve just screwed yourself.

David

Share this post


Link to post
Share on other sites
I didn''t even think to use the Release instead of Debug, god I feel like an ass now!!! Anyways, delta-z if I can do opengl code in full assembly language I think that would be the point where people start thinking I''m an android. (:

Give Microsoft a few years and we''ll probably have Visual ASM, won''t that be the day. (:

Well ok I just ran it under Win32 Release, I think I''m probably the only one who would notice the speed difference since I''ve compiled it about 21734271563412674537216543.2 times, but I have all my textures and state changes are grouped as best as they can be. The main bad thing is that I''m using glusphere in the program but I don''t know how you would make your own code to be the same as
glusphere(quadratic,vector[3],3,2); where vector[3] is incremented 0.003 each time through. I took out the lookup tables too but no speed difference, any other suggestions?

Share this post


Link to post
Share on other sites
Avoid using function you don''t know the source of.

Make sure to use triangle strips or fans (I never remember which of the two is the best).

Try to create a sphere your self and store it in your own table.
Look if it increase the speed or not.

Do you use lighting ?
Which kind ?

Not many ideas on how to improve your code, but maybe if you explain a little bit further what kind of scenes and effects you''re using...


-* So many things to do, so little time to spend. *-

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!