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 / Vsync is slowing down level loading...WHY is that?

Author
Message
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 11th Apr 2010 16:01
Whenever I use the command SET DISPLAY MODE 1024, 768, 32, 1, the loading of my levels slows the framerate down to 40 - 45 fps, while it normally should run on 85 fps.
The levels I'm loading are'nt big, they just contain the positions of the bricks (for my breakout game BRIXOID).
The first level loads very fast (has 170 bricks), the second loads a bit slower (has 182 bricks) and the framerate drops to 40 - 45 fps and upon destroying some bricks the framerate is normal again, and when loading the third level (which has 208 bricks) the fps drops down again and I have to destroy alot more bricks to regain the normal fps. It's like there's a limit on the numbre of bricks to load when using vsync on.

When I use SET DISPLAY MODE without the Vsync, then the levels load fine, but the framerate is'nt steady. There are slight hiccups, sorta speek.

At first I did'nt use the command SET DISPLAY MODE to set the resolution (I set the resolution in the DBPro editor -> properties -> screen -> Fullscreen -> Fullscreen resolution: 1024, 768, 32), and then there was no problem. I get the best performance on doing it like this. But, the problem is that I want to set the resolution for the notebook, which is'nt supported in the editor.

So, how do I solve this problem, and why is Vsync slowing down the loading of my levels??

Any suggestions or thoughts or help are much appreciated.

Thanx in advance

Cheers

Slayer rules!!! Yeaaah, man!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Apr 2010 16:20
Do you have anything sync'ing while loading, like are you doing anything but load your media?

I thought that if you don't sync, your frame rate should be uncapped. Maybe it would work if you only set the SYNC ON after loading the media - but setting the display mode first of course.


Health, Ammo, and bacon and eggs!
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 11th Apr 2010 17:47
Well, here's the code (stripped down to 390 lines - the essential stuff - hehehe )
Maybe you can see what causes the problem?



Thanks

Slayer rules!!! Yeaaah, man!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Apr 2010 18:19
Ahh, I wonder if you should SYNC RATE 0, then set the sync rate to whatever you need before the game starts. Or make your own syncing routine or use timer based movement - that way you could leave the sync rate at 0, and get the maximum speed when not syncing.

I think the sync rate defaults to 60 or something if you don't set it to 0.


Health, Ammo, and bacon and eggs!
Dark Dragon
19
Years of Service
User Offline
Joined: 22nd Jun 2007
Location: In the ring, Kickin\' *donkeybutt*.
Posted: 11th Apr 2010 18:40
Quote: " wonder if you should SYNC RATE 0, then set the sync rate to whatever you need before the game starts."


Usually what I do. I used to get the same problem, this was exactly my soulution.

The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 11th Apr 2010 21:32
Quote: "Or make your own syncing routine"

How would I do that? Is this the same as Timer Based Movement? That would require a lot of changing of my code, right?

Cheers

Slayer rules!!! Yeaaah, man!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 11th Apr 2010 21:38
Well you can work out that say, 50fps is 20 cycles (1000/50), so your main loop has 20 cycles to complete.

I would do something like this before the sync:

tim=timer()
elapsed=tim-lasttim
lasttim=tim

Then you have the elapsed time for the loop, and can wait for the remaining time...

elapsed_wait=20-elapsed
if elapsed_wait>0 then sleep elapsed_wait

Time based movement would be similar...

elapsed#=(tim-lasttim)/20.0

Then multiply that, so if your moving an object by 1 unit per frame, change...

move object 10,1.0

to...

move object 10,1.0*elapsed#


Health, Ammo, and bacon and eggs!
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 11th Apr 2010 21:40
If you're using V-Sync you shouldn't have to worry about what the sync rate is set to, just that manual syncing is on.

As for the problem, I'm not sure.
Rudolpho
20
Years of Service
User Offline
Joined: 28th Dec 2005
Location: Sweden
Posted: 12th Apr 2010 14:27
Doesn't VSync force an automatic sync each time the monitor is updated (usually something like 60 times per second)?
So in effect it works like having sync off.
I could be wrong though; maybe it just waits for the next screen refresh whenever sync is called.

The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 12th Apr 2010 20:01
@VanB:

Thanks, I'll give that time based movement a shot. Will take some time to change everything related to the movement code, but if it helps, then the better.
So, the screen sync would only update the graphics, while the timer based movement would take control of the speed things move, right? This would mean that the movement speed would stay relatively the same on different machines, while the screen refresh would vary, correct?

@Benjamin:

Upon using Vsync ON, the screen refresh is steady, but the loading of levels slows the framerate down untill the numbre of bricks on screen reaches 178 - 182 bricks. Very weird IMO.

And, when I don't use the SET DISPLAY MODE command and set the resolution in the DBPro editor, then the screen refresh is perfect, and so is the loading speed of the levels. But, there is no option to set the resolution to suit the notebook. Maybe something to consider for the next DBPro update? *hint *hint

@Rudolpho:

When I set Vsync ON and use SYNC RATE 0, then I still get 85 fps (which is the same rate in the properties settings of my monitor). I think that Vsync ON sets the framerate equal to the refresh rate of your monitor or graphicscard settings. I could be wrong, though.

Cheers

Slayer rules!!! Yeaaah, man!
Van B
Moderator
23
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 12th Apr 2010 21:02
Yup, that's a major benefit, your game is then future proof, because more powerful PC's will just make it super-smooth.


Health, Ammo, and bacon and eggs!
The Slayer
Forum Vice President
16
Years of Service
User Offline
Joined: 9th Nov 2009
Playing: (Hide and) Seek and Destroy on my guitar!
Posted: 12th Apr 2010 21:32
I was wondering though, if we can control the steadiness of moving things with timer based code, can we do that same thing for screen refreshing, and if so, how?

Thanks in advance.

Slayer rules!!! Yeaaah, man!

Login to post a reply

Server time is: 2026-07-26 14:30:54
Your offset time is: 2026-07-26 14:30:54