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 / How important is sync?

Author
Message
wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 22nd Jul 2012 03:33
It makes my games slower, choppy and causes screen tear. I don't get screen tear without sync enabled, and I don't think I grasp the importance of using the command.
Anyone willing to share some insight on this?

http://mattsmith.carbonmade.com/
basjak
16
Years of Service
User Offline
Joined: 16th Apr 2010
Location: feel like signing up for mars
Posted: 22nd Jul 2012 04:07
Sync will force the program not to draw anything on the screen unless it's called. This will make the program faster not slower. So you can draw images, bitmaps, and points to the back buffer then flush all to the screen all at once.

TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Jul 2012 04:14
You have to understand the following commands:

sync on
sync off
sync rate
sync
backdrop on
backdrop off


sync on enables manual screen refreshing. This means that the screen will only refresh when you call the sync command.

sync off disables manual screen refreshing. This means that the screen is refreshed after every single command you use. This is only useful if you're doing some kind of text adventure or something that doesn't have a main loop.

sync rate will set how long it should take to refresh your screen with sync. This is only useful if you've used sync on. Most games today use a value of 60, some games use 30. Anything faster than 60 is useless because the monitor can't physically keep up with it.

backdrop on enables the backdrop to be cleared every time you call sync. This only works if you've used sync on.

backdrop off disables the backdrop to be cleared, which means that your 3D objects or 2D images will smear on your screen. Disabling the backdrop makes refreshing your screen a tad bit faster because it doesn't have to be cleared. This is used when you're in a closed 3D world where you'll never actually be able to see the backdrop directly.

vertical sync is a technique that synchronizes your main loop with the frequency of the actual monitor of your computer. This gets rid of the problem of having "rips" between frames. You can enable vertical sync with set display mode width , height , depth , vertical_sync, where vertical_sync = 1.

All in all, you're getting screen tearing because you haven't used sync on.



TheComet

wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 22nd Jul 2012 04:22
Did use sync on, did set the sync rate to 60, set the backdrop on, placed sync at the end of the loop and set v-sync on in the set display mode command. Every program I've ever worked on in dbpro had screen tearing ONLY with sync on.
And the one I'm currently working on has constant performance drops at random times, ONLY with sync on.
So....

http://mattsmith.carbonmade.com/
Dar13
18
Years of Service
User Offline
Joined: 12th May 2008
Location: Microsoft VisualStudio 2010 Professional
Posted: 22nd Jul 2012 05:55
Quote: "So...."

Can we see some source code? Because I've never had screen-tearing with DBPro, even at 500 fps.

wattywatts
17
Years of Service
User Offline
Joined: 25th May 2009
Location: Michigan
Posted: 22nd Jul 2012 06:59 Edited at: 22nd Jul 2012 07:00
Sure, but I don't think you'll be able to see the tearing without the models and what not loaded.


http://mattsmith.carbonmade.com/
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 22nd Jul 2012 08:28
Your code runs fine here... The only suggestion I can give you is try changing this:



to this:



TheComet

Stab in the Dark software
Valued Member
23
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 22nd Jul 2012 16:11 Edited at: 22nd Jul 2012 16:16
1. The vsync parameter for the "Set Display Mode" command sets the sync rate.
Calling the "Sync Rate" Command before or after the "Set Display Mode" command is not necessary.

2. The "Sync On" command must be called after the "Set Display Mode" command.
When you call the "Set Display Mode" command it causes a reset of the Directx device.
If you call the "Sync On" command before the "Set Display Mode" command, it is as if you never called it.
If you don't call the "Sync On" command after "Set Display Mode" DBpro will handle the sync. In this case you don't need to call the "Sync" command at the end of the loop.
I believe your problem is you are not calling "Sync On", but are calling "Sync" at the end of the loop.

3."Sync On" and "Sync" are for you to manually control the sync.
If you don't call them DBpro automatically handles the sync, which is not desireable.

[img][/img]


WindowsXP SP3,Vista,Windows 7 SP1, DBpro v7.7RC7
Stab In The Dark Editor
The coffee is lovely dark and deep,and I have code to write before I sleep.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 23rd Jul 2012 06:17 Edited at: 23rd Jul 2012 06:17
Quote: "1. The vsync parameter for the "Set Display Mode" command sets the sync rate."


It doesn't exactly set the sync rate, it just makes the sync command wait for the next monitor refresh. If your monitor is running at 75Hz, your main loop will try to run at 75Hz. If your monitor is running at 60Hz, your main loop will try to run at 60Hz.

Another thing to note is that if you have vertical synchronization enabled and your game isn't able to run at full speed (too many objects, shaders etc, your computer can't handle the game fast enough), it will cause your main loop to wait for the next monitor refresh, i.e. your game will then run at exactly half of the monitor's speed (30 fps). If your game sucks even more and can't even run at 30 fps, it will run at the next smaller factor of the monitor's refresh (20 fps, 15 fps, 12 fps, etc.)

If you have vsync enabled, it's good to use sync rate 0 to allow the main loop to try and run as fast as possible.

The point I'm getting at is that your game will require timer based movement if you're using vsync.

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 25th Jul 2012 16:58
I thought the vsync parameter needed to be set to 1 not 0 to avoid screen tearing.
TheComet
18
Years of Service
User Offline
Joined: 18th Oct 2007
Location: I`m under ur bridge eating ur goatz.
Posted: 26th Jul 2012 01:59
That's what I said:

Quote: "vertical sync is a technique that synchronizes your main loop with the frequency of the actual monitor of your computer. This gets rid of the problem of having "rips" between frames. You can enable vertical sync with set display mode width , height , depth , vertical_sync, where vertical_sync = 1"


I thought he deliberately disabled it.

TheComet

Green Gandalf
VIP Member
21
Years of Service
User Offline
Joined: 3rd Jan 2005
Playing: Malevolence:Sword of Ahkranox, Skyrim, Civ6.
Posted: 26th Jul 2012 13:06
Quote: "That's what I said:"


So you did. Sorry.

Don't know how I missed that.

Login to post a reply

Server time is: 2026-07-08 12:46:59
Your offset time is: 2026-07-08 12:46:59