Allegro.cc - Online Community

Allegro.cc Forums » Programming Questions » vsync

This thread is locked; no one can reply to it. rss feed Print
 1   2   3 
vsync
Kauhiz
Member #4,798
July 2004

I was using page flipping before, but changed to double buffering, because of transcluency. I forgot to call vsync before drawing and my fps was around 45. If I add vsync the fps drops to well below 30. Do I really have to call vsync before the screen update?

---
It's Ridge Racer! RIIIIIDGE RAAAAACER!

Richard Phipps
Member #1,632
November 2001
avatar

Not really. It can help reduce tearing with double buffering, but I found it makes the tearing more obvious on my PC. Make it a user selectable option if you like..

Sirocco
Member #88
April 2000
avatar

Quote:

ot really. It can help reduce tearing with double buffering, but I found it makes the tearing more obvious on my PC.

How is that possible? If vsync is supported and properly used it will completely eliminate tearing, but you may get a low(er) frame rate.

-->
Graphic file formats used to fascinate me, but now I find them rather satanic.

Richard Phipps
Member #1,632
November 2001
avatar

When I use vsync it seems that the timer is not 100% accurate as such I see a tearing with scrolling approx 1/8th of the way down the screen and this slowly moves down the screen.

Without vsync this tearing is in a different place vertically each frame and so is less noticable.

decsonic
Member #4,150
December 2003

AFAIK allegro waits for a vsync before flipping pages.

Programmer's paranoia: Don't trust anybody's code, not even your own.

Human Modeling Tutorials

gillius
Member #119
April 2000

Richard, you are using vsync after you have drawn to the double buffer but right before you blit it to the screen? If your game is executing in constant time, and takes too long to blit, you will see a tearing always in the same spot, as you describe. That is because you are drawing only the first 1/8th of the screen before the vsync period ends and the gun reaches that point on the screen.

If you are really executing that slowly, that means you are probably getting like 1/16th of your refresh rate as frames. At 60hz that means it is taking you 8 refreshes and 9 vertical syncs to draw a frame, or 130ms per frame, just to draw. That's pretty extreme. That's less than 10fps, and that's not even including the logic.

Gillius
Gillius's Programming -- https://gillius.org/

Richard Phipps
Member #1,632
November 2001
avatar

With vsync I get 75fps. Without I get over 250+ fps.

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

With vsync I get 75fps. Without I get over 250+ fps.

Since you're monitor obviously has a refresh rate of 75, your 250+ is still only 75. Just without possible tearing. ;)

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Richard Phipps
Member #1,632
November 2001
avatar

I know that.. ::) :P

I only mentioned it to illustrate how fast the game runs when not restricted to the frequency of the monitor update.

Sirocco
Member #88
April 2000
avatar

Do you have a Radeon card? I've actually seen something very similar to that when using vsync in lower resolutions on a Radeon 7500. I'm happy to say that my 9200 doesn't have that problem ^.^

-->
Graphic file formats used to fascinate me, but now I find them rather satanic.

Yves Rizoud
Member #909
January 2001
avatar

Richard Phipps said:

With vsync I get 75fps. Without I get over 250+ fps.
(...)
I only mentioned it to illustrate how fast the game runs when not restricted to the frequency of the monitor update.

This statement confuses me...

I assume that during normal game, the logic is not linked to the display speed (I hope...)
Your FPS test shows that the time actually waited by one vsync, on average, is 140% the time you spend in one display_one_frame().
It gives a hint on how much "free" time you have, if you want more time-consuming logic or more effects to display - on your hardware at least.

But "how fast the game runs when not restricted (...)" ? If your screen has a rate of 75Hz, displaying more than 75 frames per second is NOT faster, it's only more CPU/memcopy stress...

If that's your "logic" step you want to profile, disable the display completely, or lock it at 75 fps "only"... An arcade game can easily reach 4-digit BPS count...

Last time I profiled my game, I got something like
vsync() 85% - called 60 to 85 Hz depending on screen
display() 14.9% - called 60 to 85 Hz depending on screen
logic() 0.1% - called 72 Hz

About display "shearing": drawing "as often as possible" in video memory is certain to cause it. You can fix the shearing by waiting for a vsync, IF (Sirocco, here's the catch: ) you can do all graphic operations in less time than what the monitor spends on moving back the "ion cannon" to the top of the screen : This time interval is half of screen frequency time, or even less...

Richard Phipps
Member #1,632
November 2001
avatar

Sirocco: Geforce 4 MX440SE.

Yves: vsync() waits until the next vertical blank (supposedly, I suspect on some cards this is emulated with a slightly inaccurate timer). That is why I said the game speed is restricted with vsync, because the function doesn't waits before returning.

Yves Rizoud
Member #909
January 2001
avatar

slightly inaccurate timer ?
uh-oh, this would explain some tearing I sometimes see in the lower part of the screen, even in double-buffer low-res (320x240) :-/ Geforce 256, bad, bad.
Guess I get the signal too early, and happily blit() from up to down before the thing has actually finished the previous frame.

imaxcs
Member #4,036
November 2003

Why even use vsync() when you do double buffering?

X-G
Member #856
December 2000
avatar

To reduce tearing.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

imaxcs
Member #4,036
November 2003

I also use double buffering without vsync() and it works perfectly!

X-G
Member #856
December 2000
avatar

Aren't you lucky.

Not everyone is. Double buffering without vsync can lead to evil-ass tearing on some setups.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

ReyBrujo
Moderator
January 2001
avatar

Especially in old computers which are not able to display a frame as fast as you request it to do.

--
RB
光子「あたしただ…奪う側に回ろうと思っただけよ」
Mitsuko's last words, Battle Royale

imaxcs
Member #4,036
November 2003

Quote:

Aren't you lucky.

8-)

23yrold3yrold
Member #1,134
March 2001
avatar

It's like that crash bug in your Asteroids game, imaxcs; just because it works on your computer doesn't mean it works on everyone else's.

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

Richard Phipps
Member #1,632
November 2001
avatar

I think giving the user the choice of vsync or not is best. Offering Page Flipping and Triple Buffering is even better though. :)

X-G
Member #856
December 2000
avatar

Quote:

I think giving the user the choice of vsync or not is best

Not just that, I'd consider it very rude not to give me that choice, considering how ridiculously easy it is to disable, code-wise.

--
Since 2008-Jun-18, democracy in Sweden is dead. | 悪霊退散!悪霊退散!怨霊、物の怪、困った時は ドーマン!セーマン!ドーマン!セーマン! 直ぐに呼びましょう陰陽師レッツゴー!

23yrold3yrold
Member #1,134
March 2001
avatar

Quote:

considering how ridiculously easy it is to disable, code-wise.

Heh; I added the ability to toggle vsync() to my screen update API, not because I had a need for it, but just because it was so little effort. :)

--
Software Development == Church Development
Step 1. Build it.
Step 2. Pray.

imaxcs
Member #4,036
November 2003

23 said:

It's like that crash bug in your Asteroids game, imaxcs; just because it works on your computer doesn't mean it works on everyone else's.

X-G said:

Not just that, I'd consider it very rude not to give me that choice, considering how ridiculously easy it is to disable, code-wise.

Then I will do that too! Again, something learned! :)

Cody Harris
Member #4,406
March 2004
avatar

Tearing???

What exactly is that??

I've never heard or seen anything of the likes....

My games work the same with or without vsync(), I don't notice a diff except for a slight FPS drop.

---------------------------------
Homepage - Art (Photography)
I'm QBasicer on #allegro on Freenode.

 1   2   3 


Go to: