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 don't work as it should.

Author
Message
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 6th Aug 2010 12:27
hi, i've a problem...

running my game with a "set display mode 1680,1050,32,0" the fps rate is from 75 to 110,depending on the numbers of objects on screen.

but if i write "set display mode 1680,1050,32,1" and the monitor refresh is at 60hz, the fps rate is from 60 (ok) to 35/40.... that's not good because the lower fps without screen vsync was 75.

my wish is the screen fps is alway 60. where is the (DBPRO) problem?????

thanks for your time.

ogni scarafone è bello a mamma sua.
Diggsey
20
Years of Service
User Offline
Joined: 24th Apr 2006
Location: On this web page.
Posted: 6th Aug 2010 12:42
VSync means that the fps must always be a factor of the refresh rate. If your program takes slightly more than 1/60th of a second, it will have to wait another 1/60th of a second for the monitor to refresh, making the fps 30.

I would guess that your program is taking slightly longer on every second frame (have you got any game logic that doesn't run every loop which is slowing it down?) causing that frame to miss its slot.

If you spread out your game logic more evenly over the frames, then you should be able to keep all of them above 60hz.

[b]
Hawkblood
16
Years of Service
User Offline
Joined: 5th Dec 2009
Location:
Posted: 6th Aug 2010 19:23
Try using fastsync instead of your sync command.

The fastest code is the code never written.
Benjamin
23
Years of Service
User Offline
Joined: 24th Nov 2002
Location: France
Posted: 6th Aug 2010 19:34
It's generally only advisable to use VSync if your computer can handle it, for the reason Diggsey mentioned. If you're getting uneven performance it's not a good idea, since you'll get a reduced framerate.
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 8th Aug 2010 02:02 Edited at: 8th Aug 2010 02:02
well, there's some bottle neck in my programs, still cleaning it.
i'm not so happy because without vsync it runs very fast, with vsync sometimes slow down too much. it can be a good idea to deactivate in auto the vsync when framerate go down the 60hz. but i think it's impossible.

fastsync crash the game after 2/3 seconds.

ogni scarafone è bello a mamma sua.
=PRoF=
23
Years of Service
User Offline
Joined: 17th Mar 2003
Location: Milton Keynes, UK
Posted: 8th Aug 2010 02:19
Search the forums for "Timer Based Movement"

The theory behind it is that no matter whether your game is running at 10fps, or 3000fps, then stuff on screen still happens at the same speed.

Duke E
17
Years of Service
User Offline
Joined: 10th Mar 2009
Location:
Posted: 8th Aug 2010 04:13 Edited at: 8th Aug 2010 04:40
I made a comparison snippet program to show the difference with running VSync in Window mode and in full screen (dedicated) mode, darn have to keep track of my posts offline.. i failed to find my post

Well..
"set display mode 1680,1050,32,1"
It is all good, but only setting the screen mode is not enough to get max performance, you have to use:
"Set Window Off"

If you do NOT use "Set window off" after setting the display mode you lend too much performance to the operating system, and your FPS will drop.

However we have a major drawback in setting "Set Window Off", and that is IF you need to change the focus from the game to another program.
If you Alt-Tab or Ctrl-Alt-Delete to get out of your games "maximized" window, it will reset the GFX card and that will reset all your images and objects so the DBP program will crash as it can't find the objects/images.

We can use the DBP command: "Screen Invalid()" to check if the graphics card has reset due to focus change. If we detect a "screen invalid" we have to branch out and reload all objects and images.

I suggest looking up "Timer based movement" as =PRoF= suggested, you really need that anyways.

And "Fastsync" seems to be changed in the last update. "FastSync 1" instead of Sync wont work. The added "1" as a parameter used to work, but now you can't use that as animated objects will not update after fastsync at all (Edit: may be shaders that won't update, not sure?).

@Diggsey
I have seen some posts way back stating the FPS would drop 1/2 because of loosing a single frame sync. I cant really see that happening. You will loose one frame (1/60 at 60hz) of a update but it will resume on the next update only loosing one frame unless you have so much lag it will skip more than 1/SCREENREFRESH?

Regards
Kevin Picone
23
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Australia
Posted: 8th Aug 2010 09:51
Duke E,

Vsync is generally implemented as a wait top of frame. Each time the card pushes the data to the monitor (asynchronously), it keeps the current scan line (Beam position) of it's where it's up to. The beam starts well before the first pixel on the monitor and ends long after it. The area outside, is vertical blanking gap. Which is the safe area for flips to occur.

If the screen is refreshing at 60 frames per second. Then the beam takes 16.67 milliseconds for one complete refresh cycle (top to bottom), in other words to push all the scan lines to the monitor. So on a 1024 line high display, each scan line takes (16.67/1024)= 0.016 milliseconds in per line.

So for a clean sync to catch the beam in it's top of the frame position (when the beam position is zero) is tiny. If the wait occurs when the beam position is greater than zero, it'll sit and wait until it zero rolls around again. Effectively forcing a program to run in multiples of the refresh rate.

Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 8th Aug 2010 22:40
set window off is working but some nasty windows icons on the bottom of the screen are flickering during my game. my game is fullscreen exclusive mode... what a mess.

ogni scarafone è bello a mamma sua.
baxslash
Valued Member
Bronze Codemaster
19
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Aug 2010 14:16
The suggestion about timer based movement sounds like the way forward to me. I never use vsync because my code is too sloppy and I always get the effect you are describing at the start of this thread.

I always use timer based movement now and get a pretty even framerate 90% of the time.

Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 10th Aug 2010 02:29
ah, my code move about 300 objects each loop, with different speeds and phy controls, "timer based movement" need a rewrite of all routines...
nope. i've to make my code a bit more slim. thanks.

ogni scarafone è bello a mamma sua.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Aug 2010 10:04
You shouldn't use vsync to insert an artificial delay into your game anyway. IMO it's bad practice to deliberately make your game run slower.

It would be better in the long run to use timer based movement, that way as you game increases in size, the performance won't slow the game to a crawl. (Besides, vsync only works in fullscreen exclusive mode, which is a horrible screen mode! lol)

My signature is NOT a moderator plaything! Stop changing it!
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 10th Aug 2010 15:16
maybe i'm too much old style, but i like to play in fullscreen exclusive mode, i don't think there are other display mode worth to use to make a game, play a game in a small window on the screen with desktop showing lot of windows like twitter,explorer and etc,with all my finghers on the keyboad because the game hasn't any gamepad system control, wow that's not the way i like to play.

i think fullscreen and vsync must work without fails,i would like to have a better screen sync function dbpro builted-in.

ogni scarafone è bello a mamma sua.
Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 10th Aug 2010 15:38
Why not use Windowed fullscreen like every other commercial game out there?

My signature is NOT a moderator plaything! Stop changing it!
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 10th Aug 2010 21:37
vsync doesn't work. in dbpro vsync need fullscreen exclusive mode for work.

ogni scarafone è bello a mamma sua.
Indicium
18
Years of Service
User Offline
Joined: 26th May 2008
Location:
Posted: 11th Aug 2010 01:38
Windowed fullscreen LOOKS just like fullscreen exclusive.

If you're determined to use a sync rate to control your speed( which it won't, just to make the clear ), then what's wrong with sync rate 60?

Mobiius
Valued Member
23
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 11th Aug 2010 09:23
@Ermes, That's what I said! lol
Quote: "(Besides, vsync only works in fullscreen exclusive mode, which is a horrible screen mode! lol)"


My signature is NOT a moderator plaything! Stop changing it!
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 11th Aug 2010 14:56
@Mad Nightmare

sync rate 60 makes my game run a t 66fps, flickering.

@Mobiius

yes, right.

ogni scarafone è bello a mamma sua.
DVader
22
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 12th Aug 2010 15:39 Edited at: 12th Aug 2010 16:07
Er, Vsync only works in Exclusive mode? Think you may be wrong there. Unless I am reading this wrong. Setting your resolution with the ,1 flag to enable vsync, works in any mode. Windowed, Fullscreen, and desktop. At least it reduces the frame rate down to your monitors.

Hardly a beast of a program but I tried it in all modes, as what you said didn't ring true for me. Changing the flag to 0 will affect all screen modes. I get 60 fps with it set at 1, 2000+ when I use 0.

Oh regarding full screen desktop, if you mean by icons showing your firewall messages and other such nonsense, I think you will find most commercial games suffer from this too. They do on my comp anyway

http://s6.bitefight.org/c.php?uid=103081
Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 12th Aug 2010 16:03
Quote: "Think you may be wrong there. Unless I am reading this wrong. Setting your resolution with the ,1 flag to enable vsync, works in any mode. Windowed, Fullscreen, and desktop. At least it reduces the frame rate down to your monitors."


Yes, it works fine in windowed mode here too.
Ermes
23
Years of Service
User Offline
Joined: 27th May 2003
Location: ITALIA
Posted: 12th Aug 2010 22:51
not for me. not sync at 60. from 54 to 66.

ogni scarafone è bello a mamma sua.

Login to post a reply

Server time is: 2026-07-25 13:35:33
Your offset time is: 2026-07-25 13:35:33