Obtaining the time of screen refresh

Hi folks,

I’m curious if there might be any way to determine the time at which the
screen actually refreshes. That is, so far as I understand, I can ask for a
window to update via SDL_UpdateWindowSurface, but depending on the time of
last screen refresh, it might take up to 17ms (assuming a standard LCD with
60Hz refresh rate) for my call to SDL_UpdateWindowSurface to actually yield
a change in what’s on the screen. This is OK for me, but it would help if I
could determine precisely when the update actually happens so that my
subsequent timings can take the lag into account (especially when there
might be variability in the lag depending on when I asked for the update).

Any suggestions?

I’m not afraid to poke into the source and build, but I’m having trouble
tracking down anything that might indicate the time of last refresh…

Mike–
Mike Lawrence
Graduate Student
Department of Psychology & Neuroscience
Dalhousie University

~ Certainty is (possibly) folly ~

Message-ID:
<CAB+QPJDQhHtOmWUmtMBRMpBE5GJY68+4Dk9Kc3=Hs7QCt9u5Jw at mail.gmail.com>
Content-Type: text/plain; charset=“iso-8859-1”

Hi folks,

I’m curious if there might be any way to determine the time at which the
screen actually refreshes. That is, so far as I understand, I can ask for a
window to update via SDL_UpdateWindowSurface, but depending on the time of
last screen refresh, it might take up to 17ms (assuming a standard LCD with
60Hz refresh rate) for my call to SDL_UpdateWindowSurface to actually yield
a change in what’s on the screen. This is OK for me, but it would help if I
could determine precisely when the update actually happens so that my
subsequent timings can take the lag into account (especially when there
might be variability in the lag depending on when I asked for the update).

Any suggestions?

I’m not afraid to poke into the source and build, but I’m having trouble
tracking down anything that might indicate the time of last refresh…

I don’t think there is anything. SDL is not a scientific toolkit, and
if it was, there would be a major likelihood that you would require
special hardware in order to get the desired results. Do you have said
special hardware? If not, then you need to confirm that what you do
have will do the trick. Commodity hardware and software are not
designed for neurological research or other highly time-sensitive
applications. I think you will probably need to look at OS-level
stuff, instead of a wrapper library like SDL which is designed to
abstract away details.

And can anyone tell me why neurological folks keep looking at SDL? Or
for that matter, any sort of wrapper library? This doesn’t make sense
to me.> Date: Sat, 2 Nov 2013 22:10:07 -0300

From: Mike Lawrence <mike.lwrnc at gmail.com>
To: SDL Development List
Subject: [SDL] Obtaining the time of screen refresh

This stuff is just not supported by the commodity hardware.

There have been some noises from Nvidia lately - their GPU-driven
refresh rate thing - that COULD plausibly support this kind of query.

But, alas, they are still just noises at the moment, and, in any case,
those would require certain monitor hardware, and certain
Nvidia-specific GL extensions.

In the mainstream, nothing changed - you push data to the GPU, it
draws it, framebuffer gets updated, then the discrete logic decides
it’s time to push data to the monitor, which then buffers a bunch of
frames because it can.

So, nothing like milliseconds here. More like 30ms until you can be
reasonably sure that whatever was sent to the GPU was actually drawn.
If even. And you can’t know when it was.–

./lxnt