Input lag

For questions about using Classic.

Post » Mon Dec 07, 2009 10:16 pm

I'm not sure why this happens. I guess it would be useful to narrow it down to a single setting.

I can't see how Construct could cause more than two or three frames latency given double buffering, which should appear almost instant. It might be something to do with graphics cards settings, VSync, mouse settings, or a combination. I don't know of anything I could do to rectify this at all; as far as my code does, it gets the mouse position and draws it, all in the same frame, so I can't see where such a large delay would come from!
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Dec 07, 2009 10:34 pm

[quote="Ashley":1dqxpyju]I'm not sure why this happens. I guess it would be useful to narrow it down to a single setting.

I can't see how Construct could cause more than two or three frames latency given double buffering, which should appear almost instant. It might be something to do with graphics cards settings, VSync, mouse settings, or a combination. I don't know of anything I could do to rectify this at all; as far as my code does, it gets the mouse position and draws it, all in the same frame, so I can't see where such a large delay would come from![/quote:1dqxpyju]

well, i think turning off the triple buffering AND setting the "max frames to pre-render" to 0 (default was 3 for some reason) lowers the lag A LOT. it's still noticeable, but very little. as you all stated, little lag is "normal", i'm at the point you all are, so for this thanks :) but it would be great, if there was some way to get rid of the lag completely.
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Mon Dec 07, 2009 10:40 pm

[quote="ranma":3vqqi4iw]well, i think turning off the triple buffering AND setting the "max frames to pre-render" to 0 (default was 3 for some reason) lowers the lag A LOT.[/quote:3vqqi4iw]
Out of interest, where were those settings? Are they in your graphics card driver options? What make is your graphics card?
Scirra Founder
B
359
S
214
G
72
Posts: 22,946
Reputation: 178,478

Post » Mon Dec 07, 2009 10:45 pm

[quote="Ashley":3ldwop9p][quote="ranma":3ldwop9p]well, i think turning off the triple buffering AND setting the "max frames to pre-render" to 0 (default was 3 for some reason) lowers the lag A LOT.[/quote:3ldwop9p]
Out of interest, where were those settings? Are they in your graphics card driver options? What make is your graphics card?[/quote:3ldwop9p]

I dunno about ATI cards, but there's settings for the render frames ahead on nVidia cards. You often see suggestions about changing them for games like Oblivion, to smooth things out or to help with mouse pointer lag. The triple buffering stuff is usually where the standard card quality settings are found.
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Mon Dec 07, 2009 10:47 pm

[quote="Ashley":2ik1xxea][quote="ranma":2ik1xxea]well, i think turning off the triple buffering AND setting the "max frames to pre-render" to 0 (default was 3 for some reason) lowers the lag A LOT.[/quote:2ik1xxea]
Out of interest, where were those settings? Are they in your graphics card driver options? What make is your graphics card?[/quote:2ik1xxea]

in the freaking "nvidia control panel". this said, my graphic card is nvidia :) geforce 9600gt. i was on 6600gt earlier and there was no lag, but i don't think this is the problem, i'd still bet on the triple buffering and th pre-rendered frames thing.
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Mon Dec 07, 2009 10:54 pm

[quote="ranma":o490fl92][quote="Ashley":o490fl92][quote="ranma":o490fl92]well, i think turning off the triple buffering AND setting the "max frames to pre-render" to 0 (default was 3 for some reason) lowers the lag A LOT.[/quote:o490fl92]
Out of interest, where were those settings? Are they in your graphics card driver options? What make is your graphics card?[/quote:o490fl92]

in the freaking "nvidia control panel". this said, my graphic card is nvidia :) geforce 9600gt. i was on 6600gt earlier and there was no lag, but i don't think this is the problem, i'd still bet on the triple buffering and th pre-rendered frames thing.[/quote:o490fl92]

I tried it and changing either of those made no visible difference (the lag wasn't bad to begin with for me, but could see it was there like others).

Turn v-synch off though and either using unlimited (not recommended obviously) or fixed, removes any lag. So it's obviously down to the v-synch in some way. Just a shame things look bad without it heh.

Download: No lag at all

BTW even if enabling/forcing v-synch outside of construct. It still causes the lag. And a quick check on google shows many other games and setups that suffer from it. Fix? They suggest turning v-synch off too.

Edit: Ok more testing and yup. Turn v-synch off and there's absolutely no lag whatsoever. It's not a construct bug or issue, it's a DirectX problem that apparently effects any game using it. The good news is even if you make your game with v-synch on. Someone could force it off in their nVidia control panel (I imagine ATI as well), and remove all lag if it's a problem for them. Regardless what you've set it as.

And just to make the OGL nuts happy.. this doesn't happen in that. ;)
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Tue Dec 08, 2009 12:18 am

[quote="Lost my Keys":mzxextkg]Turn v-synch off though and either using unlimited (not recommended obviously) or fixed, removes any lag. So it's obviously down to the v-synch in some way. Just a shame things look bad without it heh.[/quote:mzxextkg]

well, you set the fixed framerate to 120fps. when someone has 85hz monitor, ther will be visible choppy display. also, when I set fixed framerate to 60 fps (my screen refresh rate), the lag is still there. (i believe in 120fps, it is there also, but half as visible)
[quote="Lost my Keys":mzxextkg]
Edit: Ok more testing and yup. Turn v-synch off and there's absolutely no lag whatsoever.
[/quote:mzxextkg]

nope. i set the vsync to "force off" in nvidia control panel - no difference sadly :( so for me to minimise the lag, the settings are "max pre rendered frames - 0, tripple buffer - off, vertical synchrtonization - use application setting/off/on - does not make a difference)

i'm still using the v-synced display in construct, as using fixed or unlimited is bad - the way you see it, setting the app to fixed 120 lowers the lag, you can set it to 240 and lower it more, this is not the way to do things here :) also i'm not saying this is a construct problem, but still i'd like to know how to overcome it.
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

Post » Tue Dec 08, 2009 1:47 am

I know a bit about this, so I guess I'll explain.

To draw a frame you need to calculate it first. so:
input -> framebuffer.
Input is where the game picks up your commands and framebuffer is the screen. This is a 1-frame lag. This is the minimum you can get, there's no way around it. Think of this as an unlimited framerate, single-buffered game.
This isn't so hot, because you're drawing directly to the screen. If your drawing code takes longer than a screen refresh, the scene might be half-drawn when presented.

input -> backbuffer -> framebuffer
So this is double buffering, where you can hold one frame in a backbuffer and draw to that one, and when it's done you copy that one to the framebuffer. This means your commands will show up two frames later.

input -> backbufferA -> backbufferB -> framebuffer
And of course, triple buffering is the same idea, just bigger.

All of these were with unlimited frames per second (fps).

Now what happens with vsynch?

let's see the most common double-buffer scenario:
input -> backbuffer -> VSYNC -> framebuffer
the backbuffer is copied to the framebuffer only on a VSync, which happens 60 or whatever times per second. So now your input is delayed by one frame plus the time it takes to the next VSync.

With triple buffering.... yeah
input -> backbufferA -> backbufferB -> VSYNC ->framebuffer
your input is delayed by two frames and one Vsync.

Now, most video cards have a hardware mouse cursor, which is calculated in paralell to the rest of the screen drawing stuff and it's directly overlaid on top of the framebuffer, that's why it responds so well.

I hope this clear things up. To sum:
The fastest cursor will ALWAYS be the OS' cursor, followed by the 2-frame delay that's minimum for DirectX, with no VSync and doublebuffering.
B
3
S
2
G
4
Posts: 1,445
Reputation: 4,665

Post » Tue Dec 08, 2009 2:00 am

[quote="ranma":21qod6rw][quote="Lost my Keys":21qod6rw]Turn v-synch off though and either using unlimited (not recommended obviously) or fixed, removes any lag. So it's obviously down to the v-synch in some way. Just a shame things look bad without it heh.[/quote:21qod6rw]

well, you set the fixed framerate to 120fps. when someone has 85hz monitor, ther will be visible choppy display. also, when I set fixed framerate to 60 fps (my screen refresh rate), the lag is still there. (i believe in 120fps, it is there also, but half as visible)
[quote="Lost my Keys":21qod6rw]
Edit: Ok more testing and yup. Turn v-synch off and there's absolutely no lag whatsoever.
[/quote:21qod6rw]

nope. i set the vsync to "force off" in nvidia control panel - no difference sadly :( so for me to minimise the lag, the settings are "max pre rendered frames - 0, tripple buffer - off, vertical synchrtonization - use application setting/off/on - does not make a difference)

i'm still using the v-synced display in construct, as using fixed or unlimited is bad - the way you see it, setting the app to fixed 120 lowers the lag, you can set it to 240 and lower it more, this is not the way to do things here :) also i'm not saying this is a construct problem, but still i'd like to know how to overcome it.[/quote:21qod6rw]

The 120fps was just something I left it at, it works without lag at 60fps, 20fps, 900fps too. The point was, turning v-synch off solves the problem, at least on my end, and you can either build the game with it off, or let the user force it off via their control panel for their video card.

I did read somewhere that machines that are too fast are the ones with this problem, and ones that are slower are immune to it. Which makes me think, when you've got everything on there doing it's thing, this is probably not going to be happening then.
B
3
S
2
G
3
Posts: 628
Reputation: 2,531

Post » Tue Dec 08, 2009 2:18 am

[quote="Lost my Keys":e79o73ce]
The 120fps was just something I left it at, it works without lag at 60fps, 20fps, 900fps too.[/quote:e79o73ce]

well, it does not, when i set the fixed framerate to 60 it behaves exactly as when i turn the v-synced mode.

also,
[quote="Construct Wiki":e79o73ce]
V-Synced: [...] The best quality and smoothest display. Games should all use this option.[/quote:e79o73ce]
[quote="Lost my Keys":e79o73ce]The point was, turning v-synch off solves the problem[/quote:e79o73ce]

I'm confused :?

Thank you Madster for explaining, but i don't think the lag is 2 frames, if my monitor draws 60 frames per second, the lag seems more like about 10 frames (well, now, after fiddling with the nvidia control panel). please also don't jump to conclusions that it's bad lcd, because the hardware mouse cursor does not lag whatsoever.

Any ideas how to lower the lag even more, to the twoframes from the Madster explanation?
B
81
S
50
G
10
Posts: 555
Reputation: 13,009

PreviousNext

Return to Help & Support using Construct Classic

Who is online

Users browsing this forum: No registered users and 1 guest