OpenTTD optimizations

Forum for technical discussions regarding development. If you have a general suggestion, problem or comment, please use one of the other forums.

Moderator: OpenTTD Developers

peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1791
Joined: 30 Mar 2005 09:43

Post by peter1138 »

athanasios wrote:Seems that animation slows the game a lot.
Switch to an 8bpp graphics mode and it'll cost almost no extra CPU time at all...
He's like, some kind of OpenTTD developer.
kaan
Route Supervisor
Route Supervisor
Posts: 399
Joined: 02 Apr 2007 20:13
Location: Nørup, Denmark

Post by kaan »

Bilbo wrote:I have though of another optimization. During some tests with callgrind and one of my savegames I discovered that GetTileSlope in tile.cpp, some "complicated" function is eating 6.95% of cpu time, which is relatively lot.

I though of possible fix: cache slope data (1 byte/tile) in some array, this will mean max. 4MB of memory "wasted" on largest map (2048x2048), but those 7% of CPU cycles will be reduced to neglibigle lookups.

Do you think it is a good idea?

Actually, root cause of this was GetSlopeZ_Track in rail_cmd.cpp, eating 7.96 % of cpu time, so if this function can be rewritten to do more effectively without GetTileSlope (I have no idea what for this function is), things may be beter too and without any extra memory usage
I think madman is working on including slope info in the map.

Code: Select all

if (YouAreHappyAndYouKnowIt) {
    ClapYourHands();
}
User avatar
Bilbo
Tycoon
Tycoon
Posts: 1710
Joined: 06 Jun 2007 21:07
Location: Czech Republic

Post by Bilbo »

peter1138 wrote:
athanasios wrote:Seems that animation slows the game a lot.
Switch to an 8bpp graphics mode and it'll cost almost no extra CPU time at all...
But rest of the desktop will be in 8bpp also which is .... not good :)
If you need something, do it yourself or it will be never done.

My patches: Extra large maps (1048576 high, 1048576 wide) (FS#1059), Vehicle + Town + Industry console commands (FS#1060), few minor patches (FS#2820, FS#1521, FS#2837, FS#2843), AI debugging facility

Other: Very large ships NewGRF, Bilbo's multiplayer patch pack v5 (for OpenTTD 0.7.3)
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Post by athanasios »

peter1138 wrote:
athanasios wrote:Seems that animation slows the game a lot.
Switch to an 8bpp graphics mode and it'll cost almost no extra CPU time at all...
And how did you come into the conclusion that I didn't?

Actually it makes almost no difference if you use 8bpp-optimized or 32bpp-anim. The slowdown from animation applies to both modes. OK, when game progresses and AI players join the game 32bpp is affected more. But in the beginning of the game there is no difference. I may have to repeat what I said: Use Fast Forward in any mode with/without animation and you can tell the difference. :idea: Turn off animation when we press the FF button?

NOTE:
This behavior I tested in Windows versions.
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.
peter1138
OpenTTD Developer
OpenTTD Developer
Posts: 1791
Joined: 30 Mar 2005 09:43

Post by peter1138 »

athanasios wrote:And how did you come into the conclusion that I didn't?
Because I guessed you'd confuse "blitter" with "video mode"...

Under Windows, OpenTTD is only in an 8bpp mode when you run full screen and have fullscreen_bpp set to 8, or if your whole desktop is set to 256 colours.
He's like, some kind of OpenTTD developer.
User avatar
Korenn
Tycoon
Tycoon
Posts: 1735
Joined: 26 Mar 2004 01:27
Location: Netherlands
Contact:

Post by Korenn »

true old-fashioned 8bpp palette-shifting through interrupts is very costly... I can imagine that in real 256 color mode the speed gain is only minimal.
User avatar
athanasios
Tycoon
Tycoon
Posts: 3138
Joined: 23 Jun 2005 00:09
Contact:

Post by athanasios »

peter1138: OK, you are right regarding running in 8bpp, I forgot to change my .cfg. :oops:

Yet you are wrong in suggesting this would improve speed with animation. There is a slight improvement but it is negligent, minimal as Korenn said.

So what I previously asked/suggested remains.

I was thinking about SimuTrans: Their approach to animation in sea is not ideal. Any other way for animation like gifs or multiple sprites?

OK, I am not a programmer, but I hope my reference to this, will triger a fruitfull discussion. :wink:
http://members.fortunecity.com/gamesart
"If no one is a fool I am also a fool." -The TTD maniac.


I prefer to be contacted through PMs. Thanks.
Post Reply

Return to “OpenTTD Development”

Who is online

Users browsing this forum: No registered users and 13 guests