|
Increase FPS for a parallax platform game with 9 background levels |
Kevin Epps
Member #5,856
May 2005
|
I've been reading just about every thread for about 3 hours trying to figure out a way to improve my FPS for my ATI Rage Pro 28 card. It works fine for my Radeon x300. Does ANYONE have any suggestions? The FPS is 20 on the Rage and around 60 on the Radeon. Here's the game loop code:
I know it's pretty long. I also have a question on how I coded the blitting of the background layers. The images are small but I have them blitted in a repeating pattern. Is that the right way if I want this to run effectively? |
Frank Drebin
Member #2,987
December 2002
|
for me programs run well without using vsync(), aquire_screen and release_screen but i don't know if that makes things slower... while(speed_counter == 0){rest(1)};
|
Neil Walker
Member #210
April 2000
|
Have you tried using MapLoadVRAM? Also, does your card support paging or triple buffering? Also, your timer code seems wrong. If you are doing FPS limiting looping you should have two separate parts. One being logic that compensates for slowness and the second for pure drawing only when it needs it. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Kevin Epps
Member #5,856
May 2005
|
Hey Neil, MapLoadVRAM made my FPS even slower. Triple Buffering and Page Flipping is supported, and it's a really nice, smooth movement, but the fps is really slow. As far as the timer code, I thought that's what I was doing. Having one place that controlled the logic and one place that controlled the drawing. Is that what I'm not doing? If not, what should be changed? Hey Frank, I was actually slower when I took the while call out. |
Krzysztof Kluczek
Member #4,191
January 2004
|
Quote: Does ANYONE have any suggestions? Think about OpenGL/Direct3D if you'd like to achieve good frame rates. OpenLayer (add-on library for Allegro+AllegroGL) probably can help you in case of 2D games. ________ |
Neil Walker
Member #210
April 2000
|
Well VRAM would be slower if you are blitting this to a memory bitmap afterwards. I'm not an expert by any means, but I remember someone more clever than me saying VRAM->MEMORY was very slow. So the moral is if you want to use paging/triple buffering which should increase speeds, you need to make sure you are doing it throughout. Oddly enough, the third and final exciting part of my AXL projects (as below) is the framework and I've just incorporated a complete system for handling double/paged/triple buffering amongst other things without your code needing to worry about it. Quote: Think about OpenGL/Direct3D He is using a third party tile map system that doesn't support opengl via allegro. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Kevin Epps
Member #5,856
May 2005
|
Hey Neil, I just downloaded what you have now and it's great so far! I get at least 40 FPS with the programs, which is a lot better than 20! When do you plan on having the full framework done? |
Neil Walker
Member #210
April 2000
|
It's almost done, just tracing a few bugs. It's pretty cool now. You set up exactly what you want allegro to do (graphics mode, triple/paged/double buffering, windowed/fullscreen, etc) via XML/constructors, it loads up all your animations and graphics and set you up in a nice allegro state. All you then need do is pass it the name of your functions that do logic/drawing and it sets up and runs a FPS based timer loop handing everything for you. You are given a bitmap pointer and you just use it as your drawing buffer and it is updated to the screen at the correct time, etc. It also has some helper functions, for example instead of using the limited play_sample/stop_sample it wraps up the more in-depth voice control functions (e.g. voicestart/stop - to allow you to set voice priority instead of stopping playing sounds). Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Kevin Epps
Member #5,856
May 2005
|
Oh yeah!! That's going to be awesome when you finish! Please do let me know when you do. Right now I'm using what you've already posted. Maybe I'll just wait on that to be finished before I continue coding, then. |
Neil Walker
Member #210
April 2000
|
I can gladly upload what is there if you want (it effectively works, but no documentation other than in the examples and anything other than double buffering crashes at the minute). Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Kevin Epps
Member #5,856
May 2005
|
That would be great! I'll be you test subject! |
Frank Drebin
Member #2,987
December 2002
|
Quote: I was actually slower when I took the while call out.
this is strange. |
Kevin Epps
Member #5,856
May 2005
|
Hey Guys, I think I have the triple buffering to a point were it works fine for both systems. The FPS is at 60 for both cards at 16bpp. For 32bpp, on the radeon, it's still 60 FPS and on the Rage it's 30. This is resulting from only having the tile map, player, and a big none moving background displaying. So at least it's better. I'm going to start one more thread. That's the best possible action to coding parrallax scrolling. I don't think mine is completely write as I have the scroll based off of the character's speed instead of the main layer's xoffset. Thanks for all of your help!! |
Neil Walker
Member #210
April 2000
|
Well, remember when you use paging or triple buffering the maximum fps you will get is the refresh rate of your monitor as they wait for the vertical retrace. To avoid over or under loading your system, maybe a call to try and set_refresh_rate() might help? For double buffering if you combine this with vsync it might make things a lot more smooth. Neil. wii:0356-1384-6687-2022, kart:3308-4806-6002. XBOX:chucklepie |
Tobias Dammers
Member #2,604
August 2002
|
Quote: that means if you have your timer set up to 50 BPS you'll never get more than 50 FPS though 1000000 could be drawn in this time!
Why would you want to do that? Since the logic runs at 50 fps, there is absolutely no point in drawing more frames than that - you will just render the exact same scene over and over. Waste of cpu time, better play nice and release it to the OS (read: MSN, antivirus, whatever runs in the background). Drawing 1000000 frames per second gives you nothing but an impressive number displayed on screen. Heck, you hardware can't even display more frames per second than the physical retrace rate, so why bother? --- |
axilmar
Member #1,204
April 2001
|
Dear Kevin, in order to ensure a good frame rate in a bitmap-based game, you have to do the following (assuming bitmap blitting is the issue here): 1) ensure that you use a mode like triple-buffering or page-flipping that uses vram buffers. 2) ensure your most frequently used/large bitmaps are loaded in vram. An effective way to do parallax scrolling with multiple layers is to avoid drawing blocks twice. You need a flag for each block of each layer that tells you if the block has already been covered by one of the above layers. Then you need to do two passes over your layers: a) the first pass will be from top layer to bottom in order to set the 'covered' flag; b) the second pass will be from bottom to top layer to draw those blocks at each layer that have not been covered yet. By carefully choosing block sizes (i.e. not too small, not too big) you can minimize overdraw and do many layers of scrolling (even more than 9!). |
Frank Drebin
Member #2,987
December 2002
|
Quote: Why would you want to do that? cause he wants to get more FPS! |
|