Refresh issue, "skipping"

Hi folks -

I must apologize in advance, for I really don’t know a lot about SDL, and I am
probably asking a question which has been rehashed many times on this list.
However, I’ve done a fair amount of searching on the web, and have tried a
number of fixes, but am still having problems.

I am using SDL + Open GL in an experimental scientific programming environment
where I need to be able to very precisely control what is being shown on a
screen. I’m using SDL to program a visual display for a psychophysics
experiment.

Computer info:
Dell Optiplex GX260 Intel Pentium 4 CPU 2.66GHz
running MS Windows 2000 SP4 *****
1G RAM
ATI Fire GL T2 display adapter
Philips monitor @ 75Hz, 1280x1024

“Full” hardware acceleration
Config: “Open GL Games”
“Wait for vertical retrace” checked
"enable 8bit double buffer" checked

I’ve got most things working well, but I am having problems with my moving
stimulus … I get quite regular “skips” or “hiccups” in my display, where
the movement is temporarily halted. Which means that I am getting a dropped
frame occasionally.

My hunch is that the problem has to do with the timing of my redraw loop and
buffer swap (using SDL_GL_SwapBuffers()) not matching up with the vertical
retrace. I do not, however, really see any “tearing” as far as I can tell.

Yesterday I downloaded the most recent version of SDL and added
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 ) to my script before setting the
video mode
screen = SDL_SetVideoMode( XMAX, YMAX, BPP, SDL_OPENGL|SDL_FULLSCREEN );

However, this didn’t improve the situation.

I’m seeing a dropped frame (a “hiccup” in my continuously moving stimulus)
once every 22 to 33 seconds or so … though for a while yesterday it was
happening only once every 60 seconds. Perhaps system processes are hogging
CPU and causing this to happen. Is there a way to increase SDL’s priority so
that all background processes are stopped while my program is running?

I’ve seen a few other suggestions here and there that I could use
SDL_GetTicks() and SDL_Delay() to measure how long my drawing loop is taking,
and to slow it down to better match the refresh rate. However, this seems
like it could also fail quite often, as it would be virtually impossible for
me to completely timelock my loop to the refresh rate, and any small
discrepancy would eventually accrue and lead to a dropped frame.

Am I missing something? Is there another way to address this problem? Any
help would be appreciated.

thanks,
Ed–
Ed Vessel
New York University @Ed_Vessel
Center for Neural Science
4 Washington Place, Suite 809 http://www.cns.nyu.edu/~vessel
New York, NY 10003
(212) 998-3908

Hi Ed

It sounds like your app is losing focus. Check if you’re getting SDL_ACTIVEEVENT events in the queue, and if so,
re-draw your screen.

I had the same situation today, and just putting a function to check for these events (also window resizes events)
and re-draw if necessary solved it. Quick and dirty but it does the job.

bool myAPI::checkAppFocus(void)
{
return (SDL_PollEvent(&myAPI->systemEvent)) && (myAPI->systemEvent.type == SDL_ACTIVEEVENT);
}

Hope this is of some help.

Regards
Ed (another one!!)> ----- Original Message -----

From: vessel@cns.nyu.edu (Ed Vessel)
To: sdl at lists.libsdl.org
Sent: Wednesday, 14 May, 2008 8:08:15 PM
Subject: [SDL] refresh issue, “skipping”

Hi folks -

I must apologize in advance, for I really don’t know a lot about SDL, and I am
probably asking a question which has been rehashed many times on this list.
However, I’ve done a fair amount of searching on the web, and have tried a
number of fixes, but am still having problems.

I am using SDL + Open GL in an experimental scientific programming environment
where I need to be able to very precisely control what is being shown on a
screen. I’m using SDL to program a visual display for a psychophysics
experiment.

Computer info:
Dell Optiplex GX260 Intel Pentium 4 CPU 2.66GHz
running MS Windows 2000 SP4 *****
1G RAM
ATI Fire GL T2 display adapter
Philips monitor @ 75Hz, 1280x1024

“Full” hardware acceleration
Config: “Open GL Games”
“Wait for vertical retrace” checked
"enable 8bit double buffer" checked

I’ve got most things working well, but I am having problems with my moving
stimulus … I get quite regular “skips” or “hiccups” in my display, where
the movement is temporarily halted. Which means that I am getting a dropped
frame occasionally.

My hunch is that the problem has to do with the timing of my redraw loop and
buffer swap (using SDL_GL_SwapBuffers()) not matching up with the vertical
retrace. I do not, however, really see any “tearing” as far as I can tell.

Yesterday I downloaded the most recent version of SDL and added
SDL_GL_SetAttribute( SDL_GL_SWAP_CONTROL, 1 ) to my script before setting the
video mode
screen = SDL_SetVideoMode( XMAX, YMAX, BPP, SDL_OPENGL|SDL_FULLSCREEN );

However, this didn’t improve the situation.

I’m seeing a dropped frame (a “hiccup” in my continuously moving stimulus)
once every 22 to 33 seconds or so … though for a while yesterday it was
happening only once every 60 seconds. Perhaps system processes are hogging
CPU and causing this to happen. Is there a way to increase SDL’s priority so
that all background processes are stopped while my program is running?

I’ve seen a few other suggestions here and there that I could use
SDL_GetTicks() and SDL_Delay() to measure how long my drawing loop is taking,
and to slow it down to better match the refresh rate. However, this seems
like it could also fail quite often, as it would be virtually impossible for
me to completely timelock my loop to the refresh rate, and any small
discrepancy would eventually accrue and lead to a dropped frame.

Am I missing something? Is there another way to address this problem? Any
help would be appreciated.

thanks,
Ed


Ed Vessel
New York University vessel at cns.nyu.edu
Center for Neural Science
4 Washington Place, Suite 809 http://www.cns.nyu.edu/~vessel
New York, NY 10003
(212) 998-3908


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org

  __________________________________________________________

Sent from Yahoo! Mail.
A Smarter Email http://uk.docs.yahoo.com/nowyoucan.html

I’m seeing a dropped frame (a “hiccup” in my continuously moving stimulus)
once every 22 to 33 seconds or so … though for a while yesterday it was
happening only once every 60 seconds. Perhaps system processes are hogging
CPU and causing this to happen. Is there a way to increase SDL’s priority so
that all background processes are stopped while my program is running?

This is very likely some other processes taking time. This is typically
anti-virus software or windows update. Try shutting down all other processes
and disabling these services temporarily.

See ya!
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment

Hey,

Is it also possible that your computer doesn’t like your program to be a CPU-hog? Are you throttling your frame rate? If you aren’t, you should look into it. Your program might get a hiccup whenever the OS needs to do something else. If you are controlling the frame rate, then it could possibly be due to SDL_Delay’s precision. I had a similar effect in my program that I fixed by measuring the time SDL_Delay takes to delay 1ms and then in my loop I delay for DELAYTIME minus that number. Then I burn the rest in a loop for precise timing control.

Jonny D> To: sdl at lists.libsdl.org

From: slouken at devolution.com
Date: Sat, 17 May 2008 21:13:52 -0700
Subject: Re: [SDL] refresh issue, “skipping”

I’m seeing a dropped frame (a “hiccup” in my continuously moving stimulus)
once every 22 to 33 seconds or so … though for a while yesterday it was
happening only once every 60 seconds. Perhaps system processes are hogging
CPU and causing this to happen. Is there a way to increase SDL’s priority so
that all background processes are stopped while my program is running?

This is very likely some other processes taking time. This is typically
anti-virus software or windows update. Try shutting down all other processes
and disabling these services temporarily.

See ya!
-Sam Lantinga, Lead Software Engineer, Blizzard Entertainment


SDL mailing list
SDL at lists.libsdl.org
http://lists.libsdl.org/listinfo.cgi/sdl-libsdl.org


Make every e-mail and IM count. Join the i?m Initiative from Microsoft.
http://im.live.com/Messenger/IM/Join/Default.aspx?source=EML_WL_ MakeCount