Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » Huge performance decrease from A4 to A5

Credits go to Neil Walker for helping out!
This thread is locked; no one can reply to it. rss feed Print
Huge performance decrease from A4 to A5
TeaRDoWN
Member #8,518
April 2007
avatar

So, during the last few weeks I've been updating my oldschool top down shooter from A4 to A5. I've basically replaced all Allegro functions and made small adjustments where needed. The game ran fairly ok on my Asus EEE on the A4 build (I guess it was like 50-60fps) but now with the A5 build I get like 0.5-1fps.

Even when I comment out all code from the ingame loop and only draw the HUD (1 rectangle and 2 texts in each bottom corner and a circle and a pixel current mouse location) and then flip screen I get no performance increase. Feels like I have forgotten to run something or activate something.

I understand that it can be slightly hard to guess why this is an issue without looking at the code but is there anything that is needed to avoid some Allegro functions to take too much performance / CPU-time. I tried to read the manual to find any issues and also check the examples but it's kind of hard to see what is needed.

As far as I know all bitmaps in my A4 code was memory bitmaps and I'm using the same now.

Any help and comments are welcome.

Neil Walker
Member #210
April 2000
avatar

There you go, that's your problem. Let A5 choose the bitmap not you, i.e. A5 works with video bitmaps.

Or possibly the other way round and you are trying to perform functions on video bitmaps as if they were memory bitmaps.

Another thing, porting line by line isn't necessarily a good thing, e.g. you should use events, A5 lets you perform fast blitting from the same bitmap (i.e. tile sheets)

Neil.
MAME Cabinet Blog / AXL LIBRARY (a games framework) / AXL Documentation and Tutorial

wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie

TeaRDoWN
Member #8,518
April 2007
avatar

What do you mean with "let A5 choose the bitmap"?

Ok, my code use one bitmap/sprite. Maybe not the best sollution in A5 or is it just better to have a sprite sheet in A5, not just bad to not have it?

l j
Member #10,584
January 2009
avatar

Short answer: Use video bitmaps.

TeaRDoWN
Member #8,518
April 2007
avatar

I did that first, ran out of memory while loading a level.

In A4 I assume (as with memory bitmaps in A5) there are no "bad sizes" for bitmap. But as I read in another thread I posted my 5x5 * 640x640 could be a reason why memory ran out. Someone told me to try to use 512x512 instead.

But that shouldn't be the reason why everything is so slow when I don't draw any bitmaps on screen. In my small test, all I do is this:

Is that seriously heavy operations when done to memory bitmaps?

EDIT: Have cut away even more code and found out that it is the al_draw_textf() that lag the entire game loop. Removing them gives 60fps.

Elias
Member #358
May 2000

TeaRDoWN said:

Is that seriously heavy operations when done to memory bitmaps?

Everything involving even a single memory bitmap is. You can try ex_draw_bitmap to see about how many memory/video bitmaps you can draw while staying at 60 FPS. Likely will be about 10 memory but 1000ds of video bitmaps.

--
"Either help out or stop whining" - Evert

TeaRDoWN
Member #8,518
April 2007
avatar

It's the al_draw_textf() that lowers the fps from 60 to 1. Should the font be loaded with ALLEGRO_VIDEO_BITMAP set too?

EDIT: Autch! Note to self: Fonts should NOT be loaded as memory bitmaps! Seriously!! :P

Matthew Leverton
Supreme Loser
January 1999
avatar

Allegro 5's memory bitmaps are practically unusable.

TeaRDoWN
Member #8,518
April 2007
avatar

Seriously starting to see this. Now I have to figure out how to be able to load the level since i don't think it will fit within video memory.

Is it possible to see how much free video memory there is left? Would be nice to track.

Thomas Fjellstrom
Member #476
June 2000
avatar

How large is your level? A lot of cards these days have hundreds of MBs of memory, and some have 1-2GB of memory. If your level doesn't fit into video memory, you just might be doing something wrong ;)

--
Thomas Fjellstrom - [website] - [email] - [Allegro Wiki] - [Allegro TODO]
"If you can't think of a better solution, don't try to make a better solution." -- weapon_S
"The less evidence we have for what we believe is certain, the more violently we defend beliefs against those who don't agree" -- https://twitter.com/neiltyson/status/592870205409353730

bamccaig
Member #7,536
July 2006
avatar

How large is your level? A lot of cards these days have hundreds of MBs of memory, and some have 1-2GB of memory. If your level doesn't fit into video memory, you just might be doing something wrong ;)

He did mention he was testing on an Eee so I'm guessing he has considerably less video memory than a typical PC. Based on some lazy Wikipedia'ing, it likely either has 256 MB, 512 MB, or (most likely?) no dedicated video memory at all; depending on model. With no dedicated video memory I wouldn't be surprised if the defaults have the BIOS only allocating 32 or 64 MB to video. He can probably increase that if he desires. Still, there are probably ways to work within that space more efficiently. Depending on the game's requirements that might already be plenty.

Go to: