it seems the hardware-cursor is using an independent type of vsync that probably cannot be turned off

Everything about latency. Tips, testing methods, mouse lag, display lag, game engine lag, network lag, whole input lag chain, VSYNC OFF vs VSYNC ON, and more! Input Lag Articles on Blur Busters.
Post Reply
LastExceed
Posts: 3
Joined: 26 Dec 2020, 13:52

it seems the hardware-cursor is using an independent type of vsync that probably cannot be turned off

Post by LastExceed » 27 Dec 2020, 09:15

I recently noticed that the hardware-cursor never tears, even in vsync-off scenarios. For a while I assumed I just never caught it tearing because the cursor is comparatively small and therefore unlikely to hit the scan line, but today I actively tried to enforce it by using a large vertical line as .cur and violently flicking the mouse horizontally while in an exclusive fullscreen application (which itself does show tearing, verifying there's no vsync), and wasn't able to get the cursor to tear at all.

My theory is that the position of the hardware-cursor sprite is only updated during vblank, in other words that it is still influenced by a type of vsync which is independent of the settings we're used to and might not be deactivatable. To verify this theory, I made a simple program that tracks your cursor with a vertical line (basically a software-cursor). If my theory is correct, then the hardware-cursor should be right on top of the line while at the top of the screen, but trailing behind more and more the further you go south, up to 1 full refresh time at the bottom of the screen:

phpBB [video]


And it does! Theory confirmed.

If you want to try this for yourself, you can download the program from my GitHub:
https://github.com/LastExceed/TearTest/ ... s/tag/v1.0
  • Press F11 to toggle fullscreen, use Alt+F4 to exit
  • When in exclusive fullscreen mode, the software-cursor should be tearing A LOT. If it's not, then you probably have to disable global vsync overrides in your GPU driver settings
  • Be aware that this program is rendering on-demand, which means instead of continuously drawing frames as fast as it can, it just draws a frame whenever a mouse movement event is received. If you use an FPS overlay it should therefore show FPS numbers equal to your mouse polling rate while moving, and 0 otherwise (or the last number frozen because no screen updates)
  • The software-cursor might be very slightly behind the predicted position overall as I am using ancient OpenGL 1.1 for simplicity (which is slow) and didn't bother fiddling with raw input
  • If you have trouble tracking moving objects with your eyes, look at the center of the screen and move the mouse horizontally from there. The afterimages of the hardware-cursor should always be in the middle between the afterimages of the software-cursor, whereas when doing the same at the top or bottom of the screen they should always be aligning
In windowed mode it is the other way round: the software-cursor is trailing behind the hardware-cursor by 1 full refresh time. This is because the windows desktop environment is using double buffered vsync, causing each frame to already be 1 full refresh time old by the time it is presented. if it was triple buffered then the cursors should in theory align perfectly.

I also tried this on linux with a non-compositioning WM (i3), and indeed I get the same behavior as shown in the video, so it's not Windows' fault for once.

User avatar
jorimt
Posts: 2484
Joined: 04 Nov 2016, 10:44
Location: USA

Re: it seems the hardware-cursor is using an independent type of vsync that probably cannot be turned off

Post by jorimt » 27 Dec 2020, 10:02

LastExceed wrote:
27 Dec 2020, 09:15
- why am I not allowed to use the video embed feature ?
- still can't post off-site links, hope this workaround is ok since its opensource)
Safety measures for first time posters to prevent spam (which we get a lot of without them in place). Those restrictions will lift after your first several posts.

I've edited the video and link in for you.
(jorimt: /jor-uhm-tee/)
Author: Blur Busters "G-SYNC 101" Series

Displays: ASUS PG27AQN, LG 48CX VR: Beyond, Quest 3, Reverb G2, Index OS: Windows 11 Pro Case: Fractal Design Torrent PSU: Seasonic PRIME TX-1000 MB: ASUS Z790 Hero CPU: Intel i9-13900k w/Noctua NH-U12A GPU: GIGABYTE RTX 4090 GAMING OC RAM: 32GB G.SKILL Trident Z5 DDR5 6400MHz CL32 SSDs: 2TB WD_BLACK SN850 (OS), 4TB WD_BLACK SN850X (Games) Keyboards: Wooting 60HE, Logitech G915 TKL Mice: Razer Viper Mini SE, Razer Viper 8kHz Sound: Creative Sound Blaster Katana V2 (speakers/amp/DAC), AFUL Performer 8 (IEMs)

User avatar
MaxTendency
Posts: 59
Joined: 22 Jun 2020, 01:47

Re: it seems the hardware-cursor is using an independent type of vsync that probably cannot be turned off

Post by MaxTendency » 28 Dec 2020, 06:57

Interesting. Might explain why certain settings/tweaks can feel terrible on the desktop (cursor movement) but good in game and vice versa.

LastExceed
Posts: 3
Joined: 26 Dec 2020, 13:52

Re: it seems the hardware-cursor is using an independent type of vsync that probably cannot be turned off

Post by LastExceed » 28 Dec 2020, 08:47

MaxTendency wrote:
28 Dec 2020, 06:57
Interesting. Might explain why certain settings/tweaks can feel terrible on the desktop (cursor movement) but good in game and vice versa.
Can you name an example ?

User avatar
MaxTendency
Posts: 59
Joined: 22 Jun 2020, 01:47

Re: it seems the hardware-cursor is using an independent type of vsync that probably cannot be turned off

Post by MaxTendency » 28 Dec 2020, 13:20

LastExceed wrote:
28 Dec 2020, 08:47
Can you name an example ?
Disabling HPET in BIOS (with "bcdedit /set useplatformclock true" in os, which will force PMT)
for example can cause stutters in 3d games, but desktop cursor movement is usually better.

HPET is usually hidden in newer bios, so you'll need a modded bios to disable it. On ryzen its not possible to disable it at all even with a modded bios (on newer AGESA versions, don't remember the exact version number but iirc it was right when zen2 launched)

User avatar
Chief Blur Buster
Site Admin
Posts: 11653
Joined: 05 Dec 2013, 15:44
Location: Toronto / Hamilton, Ontario, Canada
Contact:

Re: it seems the hardware-cursor is using an independent type of vsync that probably cannot be turned off

Post by Chief Blur Buster » 29 Dec 2020, 16:25

LastExceed wrote:
27 Dec 2020, 09:15
I recently noticed that the hardware-cursor never tears, even in vsync-off scenarios. For a while I assumed I just never caught it tearing because the cursor is comparatively small and therefore unlikely to hit the scan line, but today I actively tried to enforce it by using a large vertical line as .cur and violently flicking the mouse horizontally while in an exclusive fullscreen application (which itself does show tearing, verifying there's no vsync), and wasn't able to get the cursor to tear at all.
This is normal - the hardware cursor is often rendered/composited only once per refresh cycle.
LastExceed wrote:
27 Dec 2020, 09:15
[*]The software-cursor might be very slightly behind the predicted position overall as I am using ancient OpenGL 1.1 for simplicity (which is slow) and didn't bother fiddling with raw input
Or ahead.

I've managed to get a software cursor ahead of hardware sprite cursor in the Full Screen Exclusive 1000fps VSYNC OFF situation.

In fact, it even shows the raster scanout latency (www.blurbusters.com/scanout) where the "ahead-of-hardware-cursor" differential is bigger, the closer to bottom screen edge you get.

You need to write a Direct3D program (or a game engine script) running at ultra high frame rate far beyond refresh rate, to see this weird effect of software cursor ahead of hardware cursor. Only occurs with VSYNC OFF + FSE + (fps>Hz)

I discovered this in my Tearline Jedi experiments. (raster-steering of VSYNC OFF tearlines using beam racing techniques).
Head of Blur Busters - BlurBusters.com | TestUFO.com | Follow @BlurBusters on Twitter

Image
Forum Rules wrote:  1. Rule #1: Be Nice. This is published forum rule #1. Even To Newbies & People You Disagree With!
  2. Please report rule violations If you see a post that violates forum rules, then report the post.
  3. ALWAYS respect indie testers here. See how indies are bootstrapping Blur Busters research!

LastExceed
Posts: 3
Joined: 26 Dec 2020, 13:52

Re: it seems the hardware-cursor is using an independent type of vsync that probably cannot be turned off

Post by LastExceed » 29 Dec 2020, 18:07

Chief Blur Buster wrote:
29 Dec 2020, 16:25
LastExceed wrote:
27 Dec 2020, 09:15
[*]The software-cursor might be very slightly behind the predicted position overall as I am using ancient OpenGL 1.1 for simplicity (which is slow) and didn't bother fiddling with raw input
Or ahead.
By "predicted position" I was referring to my prediction in the OP, not the hardware-cursor. The latter is even further behind everywhere except at the very top of the screen

Chief Blur Buster wrote:
29 Dec 2020, 16:25
In fact, it even shows the raster scanout latency (www.blurbusters.com/scanout) where the "ahead-of-hardware-cursor" differential is bigger, the closer to bottom screen edge you get.
Yes, that's exactly what I described in my prediction. I'm a bit confused about why you are reinterating this

Chief Blur Buster wrote:
29 Dec 2020, 16:25
You need to write a Direct3D program (or a game engine script)
Why Direct3D specifically ? As you can see OpenGL works too, and I'm pretty sure Vulkan and Metal would be no different either

Chief Blur Buster wrote:
29 Dec 2020, 16:25
running at ultra high frame rate far beyond refresh rate
Eh, depends on what you call "ultra high". In theory, having your frame draw time just 1 mouse poll time (usually 1ms) shorter than monitor refresh time is all you need for a proof of concept under ideal circumstances, and I wouldn't exactly consider 53fps on a 50hz monitor "ultra fast"

Chief Blur Buster wrote:
29 Dec 2020, 16:25
Only occurs with VSYNC OFF + FSE + (fps>Hz)
The irony about the FSE requirement is that it's false in theory, but true in practice. In theory there is nothing preventing this from working in windowed mode, but in practice almost every desktop environment of every OS uses a compositor that applies Vsync globally which can only be dodged by using FSE. As described at the end of the OP, I used a non-compositing window manager on linux to prove this theory as well.

Chief Blur Buster wrote:
29 Dec 2020, 16:25
I discovered this in my Tearline Jedi experiments. (raster-steering of VSYNC OFF tearlines using beam racing techniques).
Speaking of Tearline Jedi, did you ever opensource the project in the end ? If yes, where can I find it ?

User avatar
Chief Blur Buster
Site Admin
Posts: 11653
Joined: 05 Dec 2013, 15:44
Location: Toronto / Hamilton, Ontario, Canada
Contact:

Re: it seems the hardware-cursor is using an independent type of vsync that probably cannot be turned off

Post by Chief Blur Buster » 29 Dec 2020, 18:53

LastExceed wrote:
29 Dec 2020, 18:07
By "predicted position" I was referring to my prediction in the OP, not the hardware-cursor. The latter is even further behind everywhere except at the very top of the screen
Yes, got it. Just wanted to add the interesting software-ahead-of-hardware behavior.
LastExceed wrote:
29 Dec 2020, 18:07
Yes, that's exactly what I described in my prediction. I'm a bit confused about why you are reinterating this
My reply is for other Blur Busters readers too ;)

As a courtesy to Blur Busters who often google and enter these forums at random threads, I like to add context for completeness' sake. I like sprinkling threads with relevant links, even if a bit redundant -- imagine being new to these forums but experienced in one aspect (VSYNC OFF tearline control, or raster interrupts, or hardware cursor weirdnesses), the links can be useful related reading.

If you know me around here, I am very classically verbose where possible (TMI techwise) on these advanced topics -- adding context for the sake of all thread readers...
LastExceed wrote:
29 Dec 2020, 18:07
Why Direct3D specifically ? As you can see OpenGL works too, and I'm pretty sure Vulkan and Metal would be no different either
It was just an example since it doesn't work when you try to write in higher level stuff (e.g. GUI languages, GDI, HTML5, WebGL, etc.).

But correct, any low-level OS API will work -- you just need to natively support VSYNC OFF as the quickest API-to-photons method, given the sequential serialization of 2D image data through a 1D cable to a panel on the other end of a display cable. As long as the API supports VSYNC OFF.
LastExceed wrote:
29 Dec 2020, 18:07
Eh, depends on what you call "ultra high". In theory, having your frame draw time just 1 mouse poll time (usually 1ms) shorter than monitor refresh time is all you need for a proof of concept under ideal circumstances, and I wouldn't exactly consider 53fps on a 50hz monitor "ultra fast"
Yes, this be true. Though for reliable human-visible software-ahead-of-hardware cursor behavior -- you ideally want a brute excess.

VSYNC OFF microstutters need to be kind of brute-forced out (microstutters are more visible at framerates only slightly above Hz), for the clear human vision effect. If you're doing measuring equipment/camera, it's another matter altogether (if you set up the variables sensitive enough). The clear human-visible distance-increasing behavior to appear as you move your mouse cursor around continuously near the top to bottom, like a circling the cursor -- with just your human vision, you see the distance between the hardware+software cursors more clearly vary as a linear relationship proportional to the distance of cursor away from the top/bottom edges of the screen -- this linear cursor-distance relationship versus Y axis value (distance between hardware vs software cursor continually varying), is much easier to human-eye-see if the microstutters are bruteforced out (via good excess framerate above Hz).

This weird clearly visible continual cursor-distance-varying (hardware-vs-software) behavior only occurs with VSYNC OFF, and never with VSYNC ON (a global scanout in sync with the global once-a-refresh mouse cursor compositing, either at driver level or hardware sprite level).

The fun-to-demonstrate cursor-distance-varying effect is also even easier to see at ultrahigh framerates during lower refresh rates (e.g. 1000fps at 60Hz), since the step distance of 60Hz is way huge, and the top-to-bottom is a continuum of that step distance. The more tearlines per refresh cycle, the more analog stepless the distance continuum becomes (mouse cursor smoothly visually steplessly converges to software=hardware as you reach top edge, and mouse cursor diverges software ahead of hardware, as cursor reaches bottom, to the full step distance of one 60Hz refresh cycle). If you have 16 tearlines per refresh cycle, and the mouse stepping is 16 pixels, the mouse cursor convergence occurs smoothly in 1 pixel increments as you move ~1/16ths screen height vertically, making the demo easy to human-see, when the microstutters are bruteforced out via sheer excess framerate far above Hz with many tearlines per refresh cycle.

The net result is as you circle your mouse cursor in a big circle on the screen, the software cursor clearly runs ahead of hardware cursor near bottom edge, and converges when near top edge. The way that the two cursors smoothly converges/diverges in realtime (as a function of Y axis) is fun to watch. A great demonstration of scanout latency [+0ms...+16ms] made easily human visible to the vast majority of population (instead of just esports athletes) .... in a "...Grandma, that's why esports athletes care about reducing input latency by 5ms..." easy EL15 demo that is human visible to just about anybody who has adequately functioning motion vision perception.

(Yes, if goal is electronic measurement rather than human-visible demos that most of population can see, then the brute is not necessary)
LastExceed wrote:
29 Dec 2020, 18:07
The irony about the FSE requirement is that it's false in theory, but true in practice. In theory there is nothing preventing this from working in windowed mode, but in practice almost every desktop environment of every OS uses a compositor that applies Vsync globally which can only be dodged by using FSE. As described at the end of the OP, I used a non-compositing window manager on linux to prove this theory as well.
Yes, this be true.
LastExceed wrote:
29 Dec 2020, 18:07
Speaking of Tearline Jedi, did you ever opensource the project in the end ? If yes, where can I find it ?
Not yet.

Reason: I am waiting for a co-author (or two) to collaborate with me with co-credits to do an Assembly.org submission (2021 or 2022) to exhibit this at some demoscene, before releasing to open source. There's a pouet.net thread too. For a demoscene submission, the requirement is it can only go open source only after a demoscene submission. My idea of the workflow is to share private github and collaborators improve its cross platform compatibility while adding more beamraced demos to it, and then once good enough, submitted to Assembly. Was hoping to push ahead to it, but COVID and less business travel really put this off the 2020 radar.
Head of Blur Busters - BlurBusters.com | TestUFO.com | Follow @BlurBusters on Twitter

Image
Forum Rules wrote:  1. Rule #1: Be Nice. This is published forum rule #1. Even To Newbies & People You Disagree With!
  2. Please report rule violations If you see a post that violates forum rules, then report the post.
  3. ALWAYS respect indie testers here. See how indies are bootstrapping Blur Busters research!

Post Reply