Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK .NET / FramePerSecond Performance Issue

Author
Message
Grayvyn
15
Years of Service
User Offline
Joined: 30th Oct 2008
Location: Southern California
Posted: 13th Oct 2009 06:06
I am using C# and the latest DarkGDK.Net.

I was moving along quite well with my current game project but all of a sudden, my FPS dropped from 60fps to below 10 on the same machine. I am not using any 3D commands. I am using Image and Bitmap types to .Paste or .CopyTo or .CopyFrom images to the screen. I thought it something I recently added so I removed recent features but the FPS has still remained low.

I coded in time tracing to find the bottle neck and it pointed to the Image.Paste commands as the problem. I created a fresh program with just basic loading images and pasting and it ran fast, back at 60 fps. I continued to remove and reduce my main project to trace/find the problem but still the FPS is lower than low and degrades even lower if left running.

One test I did on my basic/fresh program was load my images over and over, using the same Image array thus the previously created images get orphaned and hopefully garbage collection cleaned them up. But doing this caused the FPS to drop after about 8 iterations.

Beta testers also reported horrible FPS numbers so it isn't just my machine.

So, is there any limit on use of Image types, like the number you can have before it affects performance, etc?

Is there a different/better way to BLT 2D images to screen?

Any other ideas?

This has become very frustrating and I am on the brink of looking at other libraries like SDL and XNA.

If you want to see code then let me know.

Thanks for the help.

KISTech
16
Years of Service
User Offline
Joined: 8th Feb 2008
Location: Aloha, Oregon
Posted: 13th Oct 2009 20:50
Check Task Manager and watch your memory consumption for the program. Maybe there's a memory leak. It might help to see how much memory used by the program jumps whenever it loads/copies a new image too.

BatVink
Moderator
21
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th Oct 2009 14:19
In DBP, copy and paste of images is notoriously slow. It is better to code your own solution using memblocks.

The second point would be: Do you need to copy/paste in-game? Can this be done prior to gameplay?

Grayvyn
15
Years of Service
User Offline
Joined: 30th Oct 2008
Location: Southern California
Posted: 14th Oct 2009 21:54
@BatVink

Memblocks? gah... Is there a tutorial on it? I just checked DarkGDK.Net and DarkGDk and did not see one in there.
But what I can see from the docs is:
- I would create my images like normal, one at a time then convert to a memblock then delete the image
- I would create a memblock to represent the screen, like 800x600
- each iteration I would use copyfrom/copyto to put the needed image memblocks onto the screen memblock. Image memblocks probably stored horizontally so would copy one 32 length line at a time, 32 times for a 32x32 memblock image
- then convert the screen memblock to a image/bitmap then paste to the real screen or maybe copy the memblock right to screen if possible

That sound right-ish?

Your second question about do I need to paste to screen, not always, every where. I can optimize it and do all sorts of tricks but I want to make a game not hack the game library limits. And another issue that popped up was the more images you have in memory, regardless of size, the slower it runs. Almost like it searches through a lookup table to find the image to paste. In my test program, I set it to load 10000 images and paste from them randomly and I got 4 FPS when with about 200-400 images, I got 60 FPS.

I think my problem is the GDK is mostly about 3D with 2D falling far behind. Maybe?

Tashar
14
Years of Service
User Offline
Joined: 8th Oct 2009
Location:
Posted: 14th Oct 2009 23:11
Quote: "In my test program, I set it to load 10000 images and paste from them randomly and I got 4 FPS when with about 200-400 images, I got 60 FPS."


Was that 4 FPS during the load or 4 FPS during the paste? Also are you pasting 10,000 times per iteration? Also what type of collection did you use(hash table, array,etc)?
Grayvyn
15
Years of Service
User Offline
Joined: 30th Oct 2008
Location: Southern California
Posted: 17th Oct 2009 09:22
Quote: "Was that 4 FPS during the load or 4 FPS during the paste? Also are you pasting 10,000 times per iteration? Also what type of collection did you use(hash table, array,etc)? "


4 FPS during pasting.
For a 800x600 screen, I paste about 500 times.

The code for the dynamic array collection:


Tashar
14
Years of Service
User Offline
Joined: 8th Oct 2009
Location:
Posted: 20th Oct 2009 01:31
The next thing, How big are the images that you are pasting. Secondly are you using any blur or fade effect (these will cause a MASSIVE Slowdown.)

Anyways I draw on a 1024x768 (or the widescreen counterpart) slapping down around 3,072 (for 1024x768) for about 45 FPS. Now these images are only 32x32 images but to say the least, that's allot. also make sure on the size of your images. [10,000] is allot of images to be storing in memory.

also your code template doesn't seem right.



The reason being is that you haven't declare a size for each of the new images (or filename).

Also do you a try catch system in your code. Ex:



If you do you might want to look for an exception getting fired off. I did on (on purpose and it drug my FPS to the ground also).

Login to post a reply

Server time is: 2024-04-20 07:13:44
Your offset time is: 2024-04-20 07:13:44