Jump to content
  • Advertisement
Sign in to follow this  
Icebone1000

DX11 [dx11] vsync causes lag( little jumps from time to time)

This topic is 2541 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi

I always had this issue, but Im always forwarding for learning/caring with other stuff..
The thing is, if I enable vsync(present(1,0)), I notice some jumps, its specially noticeable with camera movments, this doesnt happen if I let the app fly its frames as it wiches..
This is also independent of drawing calls or whatever(it happens even if drawing a squad with a texture, and with the same intensity if I draw a 10MB model)..
It happens in debug(D3D11_CREATE_DEVICE_DEBUG) and release, x32 or x64.

So today I decided to investigate it, since im logging all frames and its delta times..Im not really sure if I found anything, but I did found that from times to times, I get a frame running at 0.03xx, witch is a 30fps value, and my vsynced app runs at 0.016 per frame...its just one or two frames, so Im not sure if those are indeed the ones that bumps, would one frame drop be so noticeable?

Here are some of my frames:
running normally:


64: 0.016220
65: 0.016843
66: 0.016673
67: 0.016786
68: 0.016673
69: 0.016692
70: 0.016741
71: 0.016875
72: 0.016600
73: 0.016785
74: 0.016709
75: 0.016894
76: 0.016762
77: 0.016567
78: 0.016564
79: 0.017078
80: 0.016464
81: 0.016792
82: 0.016649
83: 0.016995
84: 0.016552
85: 0.016650
86: 0.016693
87: 0.016982


some lag detected:


815: 0.016958
816: 0.017235
817: 0.016220
818: 0.016716
819: 0.016682
820: 0.017191
821: 0.031545
822: 0.001276
823: 0.016970
824: 0.016868
825: 0.016427
...
1092: 0.030895
1093: 0.000968
1094: 0.015951
1095: 0.016976
1096: 0.017013
1097: 0.017220
1098: 0.016718
1099: 0.016997
...

1103: 0.016959
1104: 0.017129
1105: 0.016124
1106: 0.016790
1107: 0.016914
1108: 0.023826
1109: 0.027350
1110: 0.016475
1111: 0.016714
1112: 0.016725
1113: 0.016943
1114: 0.016587
1115: 0.016668
...

1626: 0.016876
1627: 0.016475
WM
WM
1628: 0.016998
1629: 0.016402
WM
WM
1630: 0.031143
1631: 0.000997
1632: 0.015713
WM
WM
1633: 0.017343
1634: 0.016669
...

WM
WM
1728: 0.016917
1729: 0.016425
WM
WM
1730: 0.037844
1731: 0.000678
1732: 0.011250
WM
WM
1733: 0.016637
1734: 0.016494
WM
WM
1735: 0.017359
WM
WM
1736: 0.016343
1737: 0.017384



WM are windows messages..
What the hell can be causing this, its weird, when I searched for something like this(bumps), ppl solved by turning vsync ON, not vsync causing it...

Share this post


Link to post
Share on other sites
Advertisement
its just one or two frames, so Im not sure if those are indeed the ones that bumps, would one frame drop be so noticeable?[/quote]
Dropping from 60FPS to 30FPS, even if only a single render frame would cause a noticeable 'jump' if an object on the screen (or camera) is translating using a time delta.

What the hell can be causing this, its weird, when I searched for something like this(bumps), ppl solved by turning vsync ON, not vsync causing it...[/quote]
Glitches/bumps/jumps shouldn't be resolved with vSync unless their transformations are being updating on a frame by frame basis rather than time (you should almost always be using time for this). Vsync is implemented to reduce screen tearing, which looks like your screen has a horizontal rip in it.

I did found that from times to times, I get a frame running at 0.03xx, witch is a 30fps value[/quote]
This is likely due to the fact that your monitor is refreshing at ~60Hz, which means with vSync enabled, Present() will block until your monitor is in the vertical blank state, throttling your game to 60FPS. It will drop to 30FPS if one of the updates takes longer than 60Hz and misses one of these vBlanks, thus the next update won't get around until two vBlanks.

Share this post


Link to post
Share on other sites
[color="#1C2837"] [color="#1C2837"]if an object on the screen (or camera) is translating using a time delta.[/quote]
witch is true

[color="#1C2837"] if one of the updates takes longer than 60Hz[/quote]
when I turn vsync off, I dont get frames above 0.01, every frame is like 0.000615...Wich means(I believe) the slow down is related to the vsync causing it.

[color="#1C2837"]thus the next update won't get around until two vBlanks.[/quote]but in that case, every time a frame gets more than 0.016, i would get 0.03...? I mean, I never would get frames with delta between [0.016 .. 0.03]... Witch seems very unrealistic..what am I missing on this?

I tottaly understand vsync, (at least I though I did), but I saw present as a function that will block till certain vblanks number, in the case of 1, it waits for one, if its not before this one, it will present, not wait to the next...
The sdk says: "1,2,3,4 - Synchronize presentation after the n'th vertical blank." See, are you sure that if it gets more than 60hz it will wait for another? Cause if previous blank didnt presented anything, no tearing would occur anyway, so why wait for the next...

-_o my brain got a little blurried now

Share this post


Link to post
Share on other sites

So today I decided to investigate it, since im logging all frames and its delta times..Im not really sure if I found anything, but I did found that from times to times, I get a frame running at 0.03xx, witch is a 30fps value, and my vsynced app runs at 0.016 per frame...its just one or two frames, so Im not sure if those are indeed the ones that bumps, would one frame drop be so noticeable?

<...snip...>

What the hell can be causing this, its weird, when I searched for something like this(bumps), ppl solved by turning vsync ON, not vsync causing it...


Yes, it will most likely be noticeable. If you have constant values in your update loops, it will be significantly worse, as your objects will move/update at half speed for a frame. So if every frame you do something like object.position += 0.3, when one of these spikes occur, you're effectively going to be moving half as fast.

You might want to try enabling triple buffering in combination with vsync. If you enable VSync with a single back buffer in your swap chain, small hiccups like this are going to happen. If you add a second backbuffer to the chain, you can completely remove those hiccups with very little effort on your part.

Anandtech has a really good breakdown of why these hiccups happen, and how triple buffering addresses the problem.
http://www.anandtech.com/show/2794/3

Share this post


Link to post
Share on other sites

[quote name='Icebone1000' timestamp='1320081331' post='4878938']
So today I decided to investigate it, since im logging all frames and its delta times..Im not really sure if I found anything, but I did found that from times to times, I get a frame running at 0.03xx, witch is a 30fps value, and my vsynced app runs at 0.016 per frame...its just one or two frames, so Im not sure if those are indeed the ones that bumps, would one frame drop be so noticeable?

<...snip...>

What the hell can be causing this, its weird, when I searched for something like this(bumps), ppl solved by turning vsync ON, not vsync causing it...


Yes, it will most likely be noticeable. If you have constant values in your update loops, it will be significantly worse, as your objects will move/update at half speed for a frame. So if every frame you do something like object.position += 0.3, when one of these spikes occur, you're effectively going to be moving half as fast.

You might want to try enabling triple buffering in combination with vsync. If you enable VSync with a single back buffer in your swap chain, small hiccups like this are going to happen. If you add a second backbuffer to the chain, you can completely remove those hiccups with very little effort on your part.

Anandtech has a really good breakdown of why these hiccups happen, and how triple buffering addresses the problem.
http://www.anandtech.com/show/2794/3
[/quote]
Ive been reading about tripple buffering, and Im kind like "wtf? triple buffer is just magicly enabled by driver stuff?" I mean, as a programmer, I though tripple buffer(witch I was holding for future) is something Im as a graphics programmer would have to manage myself, setting the swap chain to have 2 back buffers, and then chosing( in my algorythm) when to render to the first and when to render to the second bbuffer, probaly involving multithreading.. Damn, how can tripple buffer be that automatic..( its what Im guessing from a fast read on articles)..

I mean, in d3d you the one who says witch is your render target, how can it be modified from outside?

Share this post


Link to post
Share on other sites
off the topic, in frank luna dx10 book:

BufferCount: The number of back buffers to use in the swap chain; we
usually only use one back buffer for double buffering, although you
could use two for triple buffering.

in dx sdk:
A value that describes the number of buffers in the swap chain, including the front buffer.


I always put 2 to this value, meaning front and back only...passing 1 to it would mean an error..but it works..makes me guess if the sdk have a wrong description

Share this post


Link to post
Share on other sites

Ive been reading about tripple buffering, and Im kind like "wtf? triple buffer is just magicly enabled by driver stuff?" I mean, as a programmer, I though tripple buffer(witch I was holding for future) is something Im as a graphics programmer would have to manage myself, setting the swap chain to have 2 back buffers, and then chosing( in my algorythm) when to render to the first and when to render to the second bbuffer, probaly involving multithreading.. Damn, how can tripple buffer be that automatic..( its what Im guessing from a fast read on articles)..

I mean, in d3d you the one who says witch is your render target, how can it be modified from outside?


Usually that is only for the OpenGL driver settings, which are a little looser about what you need to setup than DirectX. Even in DirectX, though, the driver is free to do all kinds of things with your rendering options under the hood (and it does). My video card has options to force a bunch of bells and whistles (such as anisotropic texture filtering) even in games that were made before these features existed.


off the topic, in frank luna dx10 book:

BufferCount: The number of back buffers to use in the swap chain; we
usually only use one back buffer for double buffering, although you
could use two for triple buffering.

in dx sdk:
A value that describes the number of buffers in the swap chain, including the front buffer.

I always put 2 to this value, meaning front and back only...passing 1 to it would mean an error..but it works..makes me guess if the sdk have a wrong description


According to the SDK remarks: "In full-screen mode, there is a dedicated front buffer; in windowed mode, the desktop is the front buffer."

Share this post


Link to post
Share on other sites

[quote name='kuroioranda' timestamp='1320103683' post='4879054']
[quote name='Icebone1000' timestamp='1320081331' post='4878938']
So today I decided to investigate it, since im logging all frames and its delta times..Im not really sure if I found anything, but I did found that from times to times, I get a frame running at 0.03xx, witch is a 30fps value, and my vsynced app runs at 0.016 per frame...its just one or two frames, so Im not sure if those are indeed the ones that bumps, would one frame drop be so noticeable?

<...snip...>

What the hell can be causing this, its weird, when I searched for something like this(bumps), ppl solved by turning vsync ON, not vsync causing it...


Yes, it will most likely be noticeable. If you have constant values in your update loops, it will be significantly worse, as your objects will move/update at half speed for a frame. So if every frame you do something like object.position += 0.3, when one of these spikes occur, you're effectively going to be moving half as fast.

You might want to try enabling triple buffering in combination with vsync. If you enable VSync with a single back buffer in your swap chain, small hiccups like this are going to happen. If you add a second backbuffer to the chain, you can completely remove those hiccups with very little effort on your part.

Anandtech has a really good breakdown of why these hiccups happen, and how triple buffering addresses the problem.
http://www.anandtech.com/show/2794/3
[/quote]
Ive been reading about tripple buffering, and Im kind like "wtf? triple buffer is just magicly enabled by driver stuff?" I mean, as a programmer, I though tripple buffer(witch I was holding for future) is something Im as a graphics programmer would have to manage myself, setting the swap chain to have 2 back buffers, and then chosing( in my algorythm) when to render to the first and when to render to the second bbuffer, probaly involving multithreading.. Damn, how can tripple buffer be that automatic..( its what Im guessing from a fast read on articles)..

I mean, in d3d you the one who says witch is your render target, how can it be modified from outside?


[/quote]

Triple buffering is fairly simple for a driver to do, you can force it in D3D using dxtweaker aswell.

To use Triple buffering in D3D you only need to set up a 3 buffer swapchain using swapChainDesc.BufferCount = 3, after that you can forget about it. Render Targets are not needed for this.

When you swap the buffers the driver shouldn't have to copy the content of the backbuffer to the frontbuffer, it should simply switch it so that the backbuffer becomes the frontbuffer and do rendering in the old frontbuffer. (If you run in Windowed mode there has to be a copy though)

Basically with double buffering you have:

Buffer1 (front)
Buffer2 (back)

You'll render your first frame to buffer2 and when you call present it will stall until the rendering is complete and then wait for a vblank, when it hits it will switch so that Buffer2 becomes the frontbuffer and is displayed while Buffer1 becomes the new backbuffer and your rendering will be done there.

With triple buffering you'll instead have:

Buffer1 (front)
Buffer2 (back)
Buffer3 (back)

There are basically 2 ways these 3 buffers can be used:

1) a swapchain where rendering is done to the 3 buffers in a fixed order and swaps will stall if both current backbuffers contain undisplayed frames. (Less GPU usage, higher percieved input latency(since you'll be displaying the frame you rendered 2 swaps ago instead of 1 swap ago it will take ~33.3ms for the player to see the results of his actions instead of 16.6ms) but you shouldn't get the spikes you might get with doublebuffering since a frame should always be ready and dropping below 60fps won't automatically result in 30fps but can allow you to sit at a stable 55 fps)
2) instant swaps between the 2 backbuffers overwriting undisplayed frames if necessary and swaps the inactive backbuffer(which contains the latest completed frame) with the frontbuffer when a vblank occurs. (Very high GPU usage (unless you're cpu bound), no extra input lag and no freezes, framerates can become higher than the monitors refreshrate even with v-sync enabled (extra frames are just tossed away though))

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!