Triple Buffering
-
Hi airtex2019, as you mentioned in post #4 you have pretty good high frames. BMS is not a first person shooter so is the input latency important?
I´m not an expert in pc games, just want to learn more about this stuffs. -
You control the aircraft with a joystick so yes, latency is VERY important for proper control. I have found that even plugging into a powered usb bar produces enough latency to be noticeable and affect fine control, most noticeable when you are leveling out on the horizon.
-
-
Hi airtex2019, as you mentioned in post #4 you have pretty good high frames. BMS is not a first person shooter so is the input latency important?
I´m not an expert in pc games, just want to learn more about this stuffs.I can feel it in 2 situations… 1) aero-braking on landing … ie. trying to hold nose stable around 10-13 degrees AOA. and 2) trying to hold a tight formation, eg AAR refueling. I end up with a lot of PIO (pilot-induced oscillation) which can be a pretty bad effect in RL fly-by-wire aircraft, so maybe it’s a fair aspect of the sim… lol
And (3) yeah I kinda do need every millisecond I can get when a SA-6 pops up on my RWR.
But mostly I’m just trying to tune my rig… and with the new DX11 engine maybe others will benefit from learning some more about what works best for their setups, too.
I’m a software engineer but I’ve been doing server-side stuff for 10+ years, so my graphics knowledge is way out of date… so it pays me to catch up and learn a little about this stuff.
-
Here is what I’ve learned, about triple-buffering and v-sync, while playing with NVidia’s excellent new FrameView tool and trying to tweak my 8 year old rig to get best possible performance…
Since starting this thread I eventually ended up upgrading my entire system, so now I’ve had the opportunity to play and test 4.35 on an older/slower box, and a newer/faster box.
Old and busted: Core i7-3770, GTX 1050 Ti, G-sync monitor 60-100hz
New hotness: Core i7-8700, GTX 1660 Ti, same G-sync monitor
…both Windows 10 20H2 with latest nvidia drivers[Disclaimer: I’m not a deep expert on DirectX game development, so take all this with a grain of salt… if it sounds like I know what I’m talking about, remember, I really don’t! I’m just trying to learn how stuff works. Anyone feel free to jump in and correct me if I get anything wrong. I started writing this down to help clarify my own thoughts, in pursuit of lower latency and smoother rendering, and I decided to share it here in case it helps anyone else searching the archives someday.]
- Borderless-windowed vs Fullscreen-exclusive (to DWM or not to DWM)
The first thing to learn is there is a pretty big structural difference in the rendering pipeline, depending on whether you are running windowed/borderless (where DWM composition owns the final display buffer) vs running fullscreen-exclusive, where the app is flipping the frame buffers to be displayed, directly.
The Windows DWM has the effect of making every double-buffered DirectX app behave inherently like a triple-buffered app – at the v-sync interval, the DWM “reaches in” to the app’s frame buffers and blits (copies) the latest of the 2 completed frames into the DWM-owned front-buffer. This blit is pretty fast, about 1-2ms, so it’s akin to a buffer-flip.
https://en.wikipedia.org/wiki/Desktop_Window_Manager
So it would seem the in-app triple-buffering is redundant, or even slightly harmful, when running in windowed/borderless modes. (In my testing, it seems to add 1 full frame of latency … in addition to the +1 frame of latency added by DWM). Not broken, but definitely not helpful.
- V-sync On vs Off
Another implication of running under the DWM, is that there will never be tearing – as far as I can tell, the DWM always waits for the v-blank signal before updating its front-buffer.
Without DWM, the app controls the GPU buffers directly and flips them whenever a frame is completed. With v-sync OFF there will be tearing, but very high throughput and low latency. With v-sync ON there will be no tearing, but throughput and latency will suffer because the DX app has to pause, briefly, potentially every frame, to wait for the next v-blank signal.
But with triple-buffering enabled, there are 2 back-buffers and 1 front-buffer. (Visualize the 2 back-buffers as side by side, not sequential – funneling down into 1 front-buffer… like two lanes on a freeway merging into one.) This allows the the CPU and GPU to work continuously, without pause – processing frames as fast as they’re able, without blocking to wait for the v-blank signal – because it is always safe to overwrite the older of the 2 back-buffers, without risk of tearing.
For BMS, it would seem that enabling triple-buffering should “imply” v-sync also enabled – after all there isn’t any point in doing triple-buffering if you’re just going to flip in the middle of a scanout (tearing) anyway! Indeed, on the NVidia Control Panel, the v-sync setting is a three-state (Off|On|Fast) where “Fast” is their implementation of tear-free triple-buffering.
(Strangely, with TB=on and VS=off, I do see a little bit of tearing happening when I look around quickly. Not sure why. But it doesn’t quite look like “normal” tearing… it looks more blocky, and seems limited to the cockpit, not the outside terrain or clouds. I have no idea what that means. This blocky-tearing doesn’t happen with NVidia’s v-sync=Fast triple buffering, on my systems – only with the BMS in-app triple-buffering.)
Alternatively, turning v-sync=on (with triple-buffering=on) affects the pacing of the BMS game loop – as one would expect, it lowers overall CPU and GPU utilization, and caps framerate to the monitor’s refresh rate. But in doing so, that wipes out most of the benefit of triple-buffering.
- Bottlenecks
Even with high-rez clouds and textures, shadows enabled, max AF and AA, my old rig is pretty heavily CPU-constrained. (CPU frame-time ~18ms, GPU render-time ~6ms.) It was hard to gain any value out of triple-buffering.
But my newer rig is able to push 100+ fps pretty consistently, and triple-buffering seems to have the effect of smoothing things out nicely, especially when running at a lower monitor refresh rate, eg 60hz.
On both my old and new rigs (without triple-buffering) I sometimes see a flicker or stutter… I don’t know if it’s a hardware or software glitch but it is visible in FrameView/PresentMon logs… a hiccup in the timing of every 87th frame. I have no idea if this is due to some important calculation BMS is performing in the background, or some sort of runtime garbage collection, or just a bug. But every 87th frame takes about 5-10ms longer than average… and a 7ms stutter is enough to drop p99 framerate from 100 to below 60! This happens on both of my Windows 10 rigs, regardless of DWM mode on/off, G-sync on/off, v-sync on/off, high or low refresh rates… it’s a mystery.
But! Somehow triple-buffering seems to be effective at smoothing that out. Partially due to randomizing the time-to-display latency of every single frame, by about 7ms… so a 7ms stutter once every 87 frames becomes entirely unnoticeable. But also it seems to change something fundamental in the game loop – I no longer see an obvious 5-10ms stutter between Present() calls, in the PresentMon logs, with TB enabled.
CONCLUSIONS
In general, the technique of triple-buffering is sound when you have upstream components capable of producing frames much faster than they can be consumed downstream (ie. a fast CPU and GPU, and low refresh-rate monitor). So, if you have a fairly modern, mid-to-high-end gaming PC, and are content with a modest ~60hz monitor refresh rate, it’s worth giving triple-buffering a try.
Either the in-app triple-buffering, or NVidia’s v-sync=Fast setting, for me, really seem to smooth out the microstutters and hiccups I get in other modes, and lower my overall average input-latency. (But, on my system, NVidia’s fast-sync has less tearing/jaggies, and also seems to have less impact on latency when alt+enter swapping over to borderless-windowed mode.)
But if you have an older PC that’s not delivering 60fps… or a newer PC that you’re trying to max out the framerate, driving a 120hz or higher monitor… triple-buffering is probably just going to get in the way.
Lastly… if you aren’t trying to squeeze every last millisecond, and you want to avoid tearing, while also enjoying the convenience of running in windowed/borderless mode (eg. easy alt-tab’ing) then definitely leave triple-buffering OFF and just let Windows DWM do its thing… it’s essentially forced triple-buffering.
FOOTNOTES
a) The “triple buffering” setting in the NVidia control-panel appears to be only relevant for OpenGL games – not applicable to Falcon BMS at all.
b) The “v-sync” setting in NVCP only applies when running fullscreen-exclusive (this includes the “fast” and “adaptive” v-sync modes) and effectively acts as an override to whatever the in-app settings may be. Note that v-sync=Fast is, essentially, NVidia’s implementation of triple-buffering.
c) Don’t forget you can switch between borderless-window and fullscreen-exclusive at any time with [Alt+Enter].
-
c) Don’t forget you can switch between borderless-window and fullscreen-exclusive at any time with [Alt+Enter].
…cc… if BMS doesn’t crash … oh it does work , just not everytime :twisted: (in 3D , on 2D map it works… can’t say that it ever crashed) - but I’m on AMD so…
-
@airtex2019…
the triplebuffering v-synch overkill.
it’s so simple and yet so complicated…
If I had to come up to a conclusion after your marvelous post which many will read few will understand and keep saying why i get this but I did this and they say that and so on and so forth…
would be…
try them and stick with the fluent smooth experience, don’t focus on it, live with it. -
If you are on AMD just lock your FPS with chill to your monitors refresh, works like a charm
-
That is good “quadro” card which handles most visual things to your screen by itself and don’t need time from Y computer’s CPU to aid it +transfer time. Make round things round in your screen without help of CPU etc.
DX cards use computer’s CPU to do same if they cant keep up.
That just simplified short story.
-
And with a GSync monitor, what is the best config??, I know that is different to V-sync but what is your experience??
Enviado desde mi SM-A530F mediante Tapatalk
-
And with a GSync monitor, what is the best config??, I know that is different to V-sync but what is your experience??
Enviado desde mi SM-A530F mediante Tapatalk
Depends on your computer. If you set lower refresh speed on demand you probably get more decent stable output on monitor.
-
And with a GSync monitor, what is the best config??, I know that is different to V-sync but what is your experience??
Enviado desde mi SM-A530F mediante Tapatalk
I have a G-sync monitor too … did a lot of testing with it, enabled and disabled. In the context of triple-buffering, I found G-sync doesn’t add a lot of additional value. (Although the opposite is true – if you don’t have G-sync or Freesync, then TB or nvidia Fast-sync, is probably worth trying.)
Fundamentally, the way G-sync interacts with DWM or fullscreen-exclusive triple-buffering, isn’t all that different to how it works without G-sync. There is still a v-blank signal, just now it’s a much wider window of time that the OS or the app has, to scanout the next frame to the monitor. But with TB enabled (and assuming your CPU/GPU are running faster than your monitor’s refresh rate, which is the whole point) there will almost always be a new frame ready and waiting, at the start of the sync window – so G-sync doesn’t end up being much of a factor.
-
If you are on AMD just lock your FPS with chill to your monitors refresh, works like a charm
Frame-rate limiter is something I forgot to mention … without it, your CPU and GPU will run very hot, with triple-buffering enabled! Although no different than running v-sync=off (tearing).
For BMS with triple-buffering, I’m finding I like to limit max fps to around 1.3x - 1.5x my monitor’s refresh rate. So eg. for 60hz monitor, set max frame rate = 80 or 90.
The theory: you want to avoid capping fps close to your refresh rate, or any even multiple of your refresh rate … ie. at 60fps the triple-buffer would rarely have any benefit, and at 120fps you’d begin dropping all the odd frames and showing the even frames.
But by keeping the CPU/GPU producing frames about 33% faster than they get pulled from the triple-buffer, it keeps the TB populated with fresh, recent frames, helps smooth out any frametime spikes/hiccups, and only drops around 25% of the rendered frames so your PC doesn’t heat up your whole room… lol
Also, when setting a frame-rate limit, it may be useful to set Low Latency Mode=on (this used to be a setting called Max pre-rendered frames=1) to avoid building up a queue between the CPU and GPU (if your CPU is faster than your GPU).
-
Good morning to all, and airtex in particular.
Dear friend, I’m dropping (not a bomb at your address, cool there ) these few lines of mine just to let you know my high appreciation for having made me, not an expert for sure, more conscious about the high possibilities of improvement, unveiled until now, in enjoying more and more my GTX 2080Ti card, which I feel to be a satisfied owner of.
I’m also planning to buy a 3090 one of these days, but this is another matter. Of course.
Again, thanks a lot, mate. A big ‘thumbs up’ to you.
Have a nice (and safe! Most of all) day.
With best compliments and regards.
-
a good article too imho
https://blurbusters.com/gsync/gsync101-input-lag-tests-and-settings/btw I am not an expert, jut wanted to share. don’t kill the messenger
-
a good article too imho
https://blurbusters.com/gsync/gsync101-input-lag-tests-and-settings/btw I am not an expert, jut wanted to share. don’t kill the messenger
Yep blurbusters is solid advice. This article direct from NVidia is also worth reading and understanding… (sorry can’t remember if I shared it already):
https://www.nvidia.com/en-us/geforce/guides/system-latency-optimization-guide/For BMS I tried really hard to get G-sync + v-sync working to my liking … after all G-sync probably added $200 to the price tag of my monitor.
But so far I haven’t found a way around that weird flicker / stutter every 87th frame or so, and also keeping latency low… so I’ve turned off G-sync (and v-sync) and switched to triple-buffering. And ordered a better cpu cooling fan from amazon… lol
-
Well, dear airtex, I didn’t need to do anything more or else on my system than following those hints you posted before.
Believe it or not, they succeeded - I’m always at not less that 110 fps in any situation.
And please note that my card wasn’t performing too bad until then, and I have no G-Sync monitor either.Thanks once again for all, and with best regards.
-
Frame-rate limiter is something I forgot to mention … without it, your CPU and GPU will run very hot, with triple-buffering enabled! Although no different than running v-sync=off (tearing).
For BMS with triple-buffering, I’m finding I like to limit max fps to around 1.3x - 1.5x my monitor’s refresh rate. So eg. for 60hz monitor, set max frame rate = 80 or 90.
The theory: you want to avoid capping fps close to your refresh rate, or any even multiple of your refresh rate … ie. at 60fps the triple-buffer would rarely have any benefit, and at 120fps you’d begin dropping all the odd frames and showing the even frames.
But by keeping the CPU/GPU producing frames about 33% faster than they get pulled from the triple-buffer, it keeps the TB populated with fresh, recent frames, helps smooth out any frametime spikes/hiccups, and only drops around 25% of the rendered frames so your PC doesn’t heat up your whole room… lol
Also, when setting a frame-rate limit, it may be useful to set Low Latency Mode=on (this used to be a setting called Max pre-rendered frames=1) to avoid building up a queue between the CPU and GPU (if your CPU is faster than your GPU).
Let me understand, is vsync on or off.
-
Let me understand, is vsync on or off.
V-sync OFF*. It would defeat the point … triple-buffering is all about not tearing, while not blocking on the v-blank signal from the monitor.
(*If you have Nvidia graphics, the control panel offers a setting for v-sync called ‘Fast’ which is their implementation of triple-buffering. I really like v-sync=Fast, (a) because it works in all games, and (b) it also steps out of the way when running in windowed/borderless mode which is essentially triple-buffered always courtesy of how the DWM works.)
So, to recap… two ways to enjoy triple-buffering:
-
Nvidia control panel: v-sync=off; Falcon in-game: v-sync=off, triple=ON
…then be sure to run in fullscreen-exclusive mode; borderless/window will work ok but have extra latency -
Nvidia control panel: v-sync=Fast; Falcon in-game: v-sync=off, triple=off
…then run in either windowed, borderless or fullscreen, as you prefer, with no significant difference in latency
-
-
Would be good to have a PDF guide with all those thing summed-up. We could even maybe add it BMS documentations ….