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.

DarkBASIC Professional Discussion / Low Frame Rate, help ?

Author
Message
Serge Adjo
19
Years of Service
User Offline
Joined: 3rd Aug 2006
Location:
Posted: 15th May 2010 23:47
I'm getting a low FPS on my 3D projet, the frame rate is very low. I don't know what to do: textures are tiny (16x16 pixels) and little. polycount is not high since I use 'plain objects' that are very simple maybe 60 polys at all...
my PC is good at 3D graphics: it can run DOOM3 or FarCRY with good graphics settings...

a solution ? help please?

Dr Tank
17
Years of Service
User Offline
Joined: 1st Apr 2009
Location: Southampton, UK
Posted: 16th May 2010 01:24
Unless you want to post more info I can only give very general advice. Try changing things and see what effect they have.

If you have not many objects, it's unlikely to be that, although if there are many objects in front eachother, your graphics card may be drawing large areas to the screen - much larger than the total screen area.

If you have a lot of physics, AI and stuff, you might want to try remming that out and seeing what the speed is like. Also try changing the display mode (halve the resolution and see if problem persists.)

What FPS are you actually getting? How low is low?
The Viking
17
Years of Service
User Offline
Joined: 21st Oct 2008
Location: Asgard
Posted: 16th May 2010 03:23
As Dr. Tank said, we would need to see code. Lots of the time I know I put in too much stuff that really isn't needed and it would work fine without it. I am finally getting out of that bad habit. Try fulldesktop mode... I know that one works for me quite well. Also, look through to make sure you aren't making checks on something that doesn't need to be checked each loop.

www.myspace.com/norseblod
Serge Adjo
19
Years of Service
User Offline
Joined: 3rd Aug 2006
Location:
Posted: 18th May 2010 14:34 Edited at: 26th May 2010 09:43
@The Viking & @Dr Tank, Ok, I agree to post the program: you can click this link to download a zip file containing the full program with the working '.exe' and all the media + the 'fullsourcedump.dba' file (wich is the complete programme):
https://forumfiles.thegamecreators.com/download/2017133


If you need some explanations feel free to ask me !
please download this attached program and see what you can do to improve the frame rate.

Serge Adjo
19
Years of Service
User Offline
Joined: 3rd Aug 2006
Location:
Posted: 30th May 2010 09:49 Edited at: 30th May 2010 10:37
note that I'm using DarkAI, SParky Collision and DBP ENHANCEMENTS.
when I 'rem' the line "AI UPDATE": the program run faster, so the problem is maybe there.

the latest version is attached:
https://forumfiles.thegamecreators.com/download/2023206

Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 30th May 2010 16:29
You could make it so that the ai code only executes every 3rd loop or something similar. Try breaking what code executes when up. AI one loop, player another, other calculations. That might help.... or it might just make your program more complicated than it needs to be. So it's just a suggestions.

There some other things you can do to squeeze out faster results.

Conditional Statements (If, elseif, select)
If using AND in you statement put the variable most likely false first.


If using elseif put the statement most likely to be true first


Same with select cases too. That way you don't waste time checking something that is probably going to be false anyway.

Also try to keep things that aren't need in a loop out of a loop. That keeps the computer from doing the command needlessly several times.

Now if the functionality of your program depends on the order you check your variables then don't change it. That will just mess up your games behavior.

I hope this helps some.

If you get mad and want to type something nasty about another person do this-Type what you want to say in the box then press ctrl-a and hit delete then type what you should say.
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 30th May 2010 22:04
Quote: "If using AND in you statement put the variable most likely false first."


I'd be surprised if that made any difference. If you combine several conditions into one then each component condition gets evaluated regardless of its truth. You need to use nested if/endif's to get the savings you mention. But in any case you'd need an enormous number of such conditions each sync before the performance results became noticeable.
Jaeg
20
Years of Service
User Offline
Joined: 16th Mar 2006
Location: Indiana
Posted: 31st May 2010 00:15
Yah Kind of what I figured. Thought it wouldn't hurt to suggest anyway.

If you get mad and want to type something nasty about another person do this-Type what you want to say in the box then press ctrl-a and hit delete then type what you should say.
Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 1st Jun 2010 10:47
I took a look at your code.
The way you setup the screen and handle the timing now makes it share too much CPU with the OS. I have been over this a million times in my project and initializing the screen (set display mode) with the VSyncOn = True and having it windowed (non dedicated) just don't work. Maybe a bug.

You have two options...
1. Using the command "Set Window Off" just after the "Set Display Mode" is initialized.
This will make the game run in dedicated mode. A drawback on this is you can't Alt-Tab or change focus with out resetting the game objects and images (some other data is also lost i don't remember exactly). You have to write special cases to detect the focus change and reload ALL objects and stuff when you get the focus back.

2. Initializing the display with VSyncOn = false and don't use "Set Window Off". This will run the game at full tilt. You however need to update your object move routines with some timer based movement as it ran way too fast when i tested that.

Oh and take out the "Sync Rate ##" command in the initialization. You only need to use that is you for some reason want to limit the framerate. I for instance only use it when i want to leave CPU time for recording Video from the game, I limit it to 30 FPS as i record at that speed anyways.

Regards
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Jun 2010 14:54
Quote: "Oh and take out the "Sync Rate ##" command in the initialization"

How does that improve framerate though? If all it does is limit when the game updates it should improve on CPU useage (for other processes at least) shouldn't it?

Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 1st Jun 2010 21:46 Edited at: 1st Jun 2010 21:46
Quote: "How does that improve framerate though?"


It does not.
I added that paragraph as i recommend not using "Sync Rate" at all.

If you use "Set Display Mode" to initialize the screen the "Sync Rate" command is pretty obsolete as the VSyncOn parameter, if set to true, will link the framerate to the screen refresh.
If you do not use the "Set Display Mode" method of initializing the screen and use the "Sync Rate ##" instead you will see that a "Screen FPS()" printout does not show the correct value, it is usually some frames per second higher.

From the Help files on "Set Display Mode":
"Using SYNC RATE is something of a hack when compared to this new feature which creates a perfect VSYNC between the render and the monitor."

Regards
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Jun 2010 10:12
Quote: "From the Help files on "Set Display Mode":
"Using SYNC RATE is something of a hack when compared to this new feature which creates a perfect VSYNC between the render and the monitor.""


Thanks, I didn't know that!

BillR
23
Years of Service
User Offline
Joined: 19th Mar 2003
Location: United States
Posted: 2nd Jun 2010 14:25 Edited at: 2nd Jun 2010 14:31
You don't want to tie your code to the vSync
You don't want to run through your main program code 75 times for a 75 Hz sync rate, you game will run slow!

So use sync on.
If you don't specify sync rate 0, the default sync rate is 40, too slow
Using sync rate 0, your program code can SCREAM and have your main program code run hundreds of thousands of times each loop.
Here, try this code to see
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Jun 2010 14:50
OK, I got...

Quote: "
vSyncOn count=402300
Sync Rate count=422245
"


Do I win a prize?

Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 2nd Jun 2010 15:23 Edited at: 2nd Jun 2010 15:25
Quote: "Using sync rate 0, your program code can SCREAM "


I said that already but added that Sync Mode is unnecessary to add in your code.

There is no need to use "Sync Rate" at all in your example code.
If you do NOT add "Sync Rate 0" in your code you already specified "Sync Rate 0" as it runs unsynced from the start

However you probably want to be able to have the user change the screen resolution so "Set Display Mode Xres, YRes, ColDepth, 0"
That will set the display to no sync and "Sync Rate 0" is obsolete as it already is set to zero.

Quote: "No, that is not right - You don't want to tie your code to the vSync"


And as for running slow.
If you set the display dedicated (Set Window Off) and synced (with Set Screen Mode's VsyncON=True) it will run as fast as it can anyway. Sure you wont get faster processing of your internal game code but in dedicated mode the program will take as much power it wants, this is not the case if you run windowed with VsyncON=True. Furthermore it will run much smoother if you have processing spikes that takes longer for the game loop to process. You also eliminate "screen tearing" if you run synced to the screen refresh.
Heard people say some net games run better and they get an edge running unsynced as the code sends data faster or something, if that is true i blame it on bad game design.
(Have to write an anecdote, I made a trainer for an old MMORPG - Meridian 59. Where i hooked on to the textbox in the game interface and blasted it with spellcast messages that where sent at full speed to the server bypassing all gamebuttons. I was invisible , that is bad game design.)

To sum it up:
(With an "Set Screen Mode" setup)
1. VSyncON True - use dedicated screen mode or else you will lose performance.
2. VsyncON False - does not matter if it is dedicated or not.
3. Never use Sync Rate.

Edit spellys.

Regards
Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 2nd Jun 2010 16:02 Edited at: 2nd Jun 2010 16:18
Edited your code BillR, to show the difference with running VsyncON=True dedicated vs windowed with some load.
This is the content on what i suggested to Serge.

The VSyncON=False test here is not so interesting

You have to edit the PerformanceDependentValue global variable to a suitable value for your own system like so:
Increase this value and rerun the code until you reach a level where the "vSyncOn count Dedicated" value is just below 60FPS. Now you see the value for "vSyncOn count windowed (Non Dedicated)" will be lower, indicating that something is taking power in windowed non dedicated mode.
This is much more evident when you have graphics and stuff wizzing about on screen though.

EDIT: forgot to add "sync on" to the first two tests.



Regards

Login to post a reply

Server time is: 2026-07-25 16:20:17
Your offset time is: 2026-07-25 16:20:17