How is the target refresh rate determined in windowed G-Sync?

Talk about NVIDIA G-SYNC, a variable refresh rate (VRR) technology. G-SYNC eliminates stutters, tearing, and reduces input lag. List of G-SYNC Monitors.
PositronCannon
Posts: 9
Joined: 22 May 2024, 05:28

How is the target refresh rate determined in windowed G-Sync?

Post by PositronCannon » 22 May 2024, 08:05

The reason I'm asking the question in the topic title is because I was always under the impression that the currently focused window is the one that determines the VRR target, but I have recently discovered that is not the case for me and I'm not sure if it's expected behavior or not.

To give you some context, ever since I got this laptop (which is my first experience with G-Sync or indeed any kind of VRR solution) I noticed that I would get occasional, random stutter/judder in windowed games despite G-Sync being active (indicator enabled in NVCP) and the hardware being far from stressed in any way. This judder seemed completely random and the only way I could fix it was by disabling G-Sync and ensuring the game always runs at the display's refresh or a sub-multiple of it, to avoid V-Sync judder.

However, recently SpecialK implemented a readout for the current refresh rate in VRR, and when checking it out I noticed that the value would become erratic when any visible movement happens in other windows, despite remaining unfocused. This can be anything from an animation playing in a browser window, or a new message on a Discord window to the side. These spikes in refresh rate would match 1:1 with those visual changes in other windows, and with the stutters in-game. I can very easily trigger these spikes manually by simply hovering with the mouse over interactive elements on a background window, or doing basically anything that triggers any sort of animation in those windows (I recorded a video of this, but I can't link to external sites and it's too large for an attachment).

This behavior is consistent regardless of whether I set G-Sync to be active for fullscreen applications only (or using flip model, as is the case here) or for fullscreen+windowed. It also makes no difference if the game is using bordered or borderless windowed. I've also tried disabling VRR at the Windows level, which if anything made the behavior worse, with the refresh rate varying even more and sometimes even disengaging G-Sync entirely for a few seconds.

The OS is Windows 11 23H2. The laptop is a 2022 Acer Predator Helios 300 with an RTX 3060, with the latest Nvidia drivers installed. I even tried reverting to Acer's provided drivers but there was no difference in this sense. The laptop is using the Nvidia GPU exclusively, as it has a MUX switch and I have the iGPU disabled entirely, just to rule out any Optimus nonsense.

Again, for all I know this is expected behavior and that's just how it is, but I find it strange since everything I've seen talking about this always refers to the focused window dictating the refresh rate, and animations in *other* windows stuttering, not the other way around which just doesn't make any practical sense. I'm very sensitive to judder so this is kinda driving me crazy, and if I have to minimize all other windows to avoid this then it kinda defeats the whole reason to use windowed mode, I'd just use borderless fullscreen instead to at least keep the seamless alt-tabbing. Plugging in an external monitor isn't always a practical option, and aside from this one quirk windowed mode suits my needs just fine anyway.

Any help or guidance with this would be greatly appreciated.

User avatar
RealNC
Site Admin
Posts: 3793
Joined: 24 Dec 2013, 18:32
Contact:

Re: How is the target refresh rate determined in windowed G-Sync?

Post by RealNC » 22 May 2024, 19:16

Does it happen with DX12 games too? I ask this because you don't need Nvidia's windowed g-sync "hack" for those. Set g-sync only for fullscreen, not windowed, and test with a DX12 game in windowed mode. G-sync should still work (because of MPO, where even windows can be accessed as if they were fullscreen.)

If that works fine, then your issue is simply a quirk of Nvidia's windowed mode g-sync hack. It never really worked 100% reliably (it basically hijacks DWM at a low level, which isn't even supported by the OS.) It mostly works, but can have issues, especially if multiple windows are visible.

The proper way to have windowed mode have g-sync is for games to use a presentation mode that allows MPO to work. DX12 games should always work, some DX11 games also work (but many do not.) I believe you can use Special K for DX11 games to force a dxgi flip model so they get g-sync in windowed mode without having to enable windowed mode g-sync in the nvidia panel. I haven't tested it myself so I'm not sure if it only helps for borderless window or also works with normal windows. Some more info here:

https://wiki.special-k.info/en/SwapChain
SteamGitHubStack Overflow
The views and opinions expressed in my posts are my own and do not necessarily reflect the official policy or position of Blur Busters.

PositronCannon
Posts: 9
Joined: 22 May 2024, 05:28

Re: How is the target refresh rate determined in windowed G-Sync?

Post by PositronCannon » 23 May 2024, 06:04

Yep, it happens in DX12 games as well. Just to make sure the change was applying and to eliminate all possible factors, after setting NVCP to only support fullscreen G-Sync I also disabled windowed optimizations on the Windows side, and then confirmed that G-Sync was only engaging for DX12 games and not DX11, as expected. I had only enabled windowed G-Sync on NVCP recently anyway, as a couple of older games I've been playing needed it, but otherwise I'd been using fullscreen-only for a long time, since as you say SpecialK also makes that work with windowed DX11 games and I was aware of the NVCP windowed G-Sync option being an ugly hack. But this behavior has always happened regardless, so I was pretty sure that was not the cause (and it's the first thing I tried anyway).

Also, it turns out it's not just movement in other windows that can cause this, it's *any* movement whatsoever on screen, including the taskbar and system tray. Realizing this has finally explained another issue I'd been having, that being a persistent once-per-second stutter that happened in some games. All I knew is that LFC was a factor, because the obvious periodic stutters would only happen in 60 fps games, which engages LFC as the minimum refresh on my laptop display is 72 Hz (as reported by SpecialK - seriously this program is a godsend). The moment I went above 72 fps the stutters would become far more rare, but still not completely eliminated.

And it's only now that I realize the root cause of those stutters: I have CPU and GPU temperature indicators in the system tray. And these indicators update at a rate of... once per second. Talk about an eureka moment. Disabling those has also made the refresh rate readout far more stable than it was before, pretty much pinned to the framerate +/- 0.1 Hz, as opposed the +/-2 Hz that was common before and I thought was just normal variation. Same when LFC is engaged, which previously would vary even more and that's probably the reason why the stuttering was far more obvious in LFC. This also explains why I would get occasional microstutter that did not seem related to anything happening in other windows - in reality the microstutter is *always* there as long as those indicators are active, just rarely noticeable since we're talking about ~2 Hz variations for the most part.

Regardless, the core issue remains. I just don't get why the refresh rate is being determined by things happening outside the focused window, even when using a DX12 game and eliminating all other factors. Maybe that is just how it is after all with windowed games in general? Or maybe it's just something with my laptop implementing G-Sync in a bizarre way? For what it's worth, this other recent topic mentions a similar behavior but with multiple monitors instead, which may or may not be related: viewtopic.php?f=5&t=13393
I know multimonitor setups are a can of worms for this stuff (actually reason #1 I stick to my laptop's internal display for gaming, every time I've tried it's a stutterfest, probably because of mismatched refresh rates) so it may be a different issue entirely, I don't know.

Honestly G-Sync has been kinda disappointing overall, it's great when it works but it's turned out to have so many quirks outside of "single monitor + fullscreen" situations that I've spent countless hours trying to figure out, only to end up just going back to vsync and manually matching the framerate to the refresh (or viceversa) half the time, when avoiding that kinda thing was specifically the reason for me to seek out a VRR laptop. Having to use vsync itself is whatever since I'm not very sensitive to input lag (I can play triple buffered games without noticing a thing, I was primarily a console player until about a year ago after all), but judder/stutter is just a big nope for me.

User avatar
RealNC
Site Admin
Posts: 3793
Joined: 24 Dec 2013, 18:32
Contact:

Re: How is the target refresh rate determined in windowed G-Sync?

Post by RealNC » 23 May 2024, 06:07

My suspicion is that whenever DWM needs to draw something, g-sync is temporarily disabled so DWM can take control, and then re-enabled again, causing a hiccup.

Edit: I just did a quick test with a DX12 game (Rise of the Tomb Raider) in windowed mode and with CoreTemp running, showing temps in the system tray (they change once per second) and it doesn't happen here. So... no idea :P
SteamGitHubStack Overflow
The views and opinions expressed in my posts are my own and do not necessarily reflect the official policy or position of Blur Busters.

PositronCannon
Posts: 9
Joined: 22 May 2024, 05:28

Re: How is the target refresh rate determined in windowed G-Sync?

Post by PositronCannon » 23 May 2024, 06:27

Yeah, that's definitely sounding like it. At this point I'm mostly just curious to know if this is normal behavior and other people can also reproduce it (especially on desktops, which have less chance of doing things in weird ways than laptops). Otherwise I've already resigned myself to just sticking to fixed refresh for windowed games, honestly I don't even lose much since I always cap framerate in games for temperature/fan noise reasons anyway, it's mostly just the extra overhead of having to match refresh rates that VRR gives you a "hands-free" solution to. At least SpecialK also helps with that by letting you set per-game refresh rates, but it's sadly not compatible with every game.

PositronCannon
Posts: 9
Joined: 22 May 2024, 05:28

Re: How is the target refresh rate determined in windowed G-Sync?

Post by PositronCannon » 23 May 2024, 06:29

Just saw your edit, that's definitely interesting. If it's not too much trouble, could you try and force a more obvious change to the refresh rate by wiggling the mouse around another visible window with interactive elements, or having a video playing or something? If that still doesn't reproduce it, then it's definitely something specific to my setup (so I'd be inclined to blame Acer lol).

User avatar
RealNC
Site Admin
Posts: 3793
Joined: 24 Dec 2013, 18:32
Contact:

Re: How is the target refresh rate determined in windowed G-Sync?

Post by RealNC » 23 May 2024, 06:45

PositronCannon wrote:
23 May 2024, 06:29
Just saw your edit, that's definitely interesting. If it's not too much trouble, could you try and force a more obvious change to the refresh rate by wiggling the mouse around another visible window with interactive elements, or having a video playing or something? If that still doesn't reproduce it, then it's definitely something specific to my setup (so I'd be inclined to blame Acer lol).
Just tried with a video player next to the game window. No issues. Perfect sync 100% of the time. Game is capped to 90FPS with NVCP cap, screen is at 165Hz, video player (I use mpv) is playing a 60FPS video.

I can't do the desktop interaction test, since all games I have installed right now will pause if I switch away from them.

I'm on a desktop (4070 Ti Super, AMD 3700X, Windows 10.) I have HAGS enabled, but I doubt this plays a role.
SteamGitHubStack Overflow
The views and opinions expressed in my posts are my own and do not necessarily reflect the official policy or position of Blur Busters.

PositronCannon
Posts: 9
Joined: 22 May 2024, 05:28

Re: How is the target refresh rate determined in windowed G-Sync?

Post by PositronCannon » 23 May 2024, 06:55

Okay, thanks for checking. I had also tried toggling HAGS just in case it had anything to do with it, but no dice. Aside from hardware, the only major difference I can think of is the OS, W10 vs W11, but who knows.

Oh well, I probably won't waste much more time trying to figure this out, but in the case that I'm bored enough to do so, this info will definitely help narrow it down. Thanks for the help!

User avatar
RealNC
Site Admin
Posts: 3793
Joined: 24 Dec 2013, 18:32
Contact:

Re: How is the target refresh rate determined in windowed G-Sync?

Post by RealNC » 23 May 2024, 07:03

PositronCannon wrote:
23 May 2024, 06:55
Okay, thanks for checking. I had also tried toggling HAGS just in case it had anything to do with it, but no dice. Aside from hardware, the only major difference I can think of is the OS, W10 vs W11, but who knows.

Oh well, I probably won't waste much more time trying to figure this out, but in the case that I'm bored enough to do so, this info will definitely help narrow it down. Thanks for the help!
One thing I forgot to mention is that my monitor is native G-sync (meaning it has a g-sync module, it's not a "g-sync compatible" one. Maybe that has something to do with it.)
SteamGitHubStack Overflow
The views and opinions expressed in my posts are my own and do not necessarily reflect the official policy or position of Blur Busters.

PositronCannon
Posts: 9
Joined: 22 May 2024, 05:28

Re: How is the target refresh rate determined in windowed G-Sync?

Post by PositronCannon » 23 May 2024, 07:27

My laptop's display does show up as G-Sync Capable on NVCP, as opposed to G-Sync Compatible, so I would imagine it's the same on that front.

If I'm really bored I may just end up trying out a W10 install out of curiosity... after all that's about the only variable I *can* change in this whole thing, given GPU drivers haven't made a difference.

Post Reply