Page 1 of 1

Vsync doesn't seem to work...

Posted: Wed May 08, 2013 13:19
by Blue Shadow
For some reason, and despite having vsync set to on, my frame rate doesn't lock to my monitor's refresh rate. I'm using GZDoom r1547 (it's a little old - I know). My current screen/monitor resolution is 1152x864 (in-game resolution is 800x600), and running in windowed mode (I also tried it in fullscreen mode, but there was no difference).

With ZDoom, vsync works fine - I get a steady 70-ish fps at the start point of E1M1 of Doom, and no more. But with GZDoom, the frame rate goes beyond that, up to 130, even though I have that option set to on.

I tried vid_maxfps with setting the max to 70, however it didn't have any effect either; the frame rate is still way up. On the other hand, cl_capfps still works.
Spoiler: System specs

Re: Vsync doesn't seem to work...

Posted: Wed May 08, 2013 13:27
by Gez
vid_maxfps isn't implemented in the OpenGL renderer.

In OpenGL, vsync is handled... by OpenGL. Look at the last line here:

Code: Select all

OpenGLFrameBuffer::OpenGLFrameBuffer(void *hMonitor, int width, int height, int bits, int refreshHz, bool fullscreen) : 
	Super(hMonitor, width, height, bits, refreshHz, fullscreen) 
{
	GLRenderer = new FGLRenderer(this);
	memcpy (SourcePalette, GPalette.BaseColors, sizeof(PalEntry)*256);
	UpdatePalette ();
	ScreenshotBuffer = NULL;
	LastCamera = NULL;

	InitializeState();
	gl_SetupMenu();
	gl_GenerateGlobalBrightmapFromColormap();
	DoSetGamma();
	needsetgamma = true;
	swapped = false;
	Accel2D = true;
	if (gl.SetVSync!=NULL) gl.SetVSync(vid_vsync);
}
This is the only place in the GL code where vid_vsync is referenced. To me, it means that your OpenGL drivers either do not support SetVSync at all (function not present) or they do but it doesn't work.

Anyways, works for me.

Re: Vsync doesn't seem to work...

Posted: Wed May 08, 2013 13:57
by Blue Shadow
Gez wrote:vid_maxfps isn't implemented in the OpenGL renderer.
Oh! I wasn't aware of that. Why is it not, I wonder? Any specific reason(s)?
To me, it means that your OpenGL drivers either do not support SetVSync at all (function not present) or they do but it doesn't work.
Not that it matters, now, but is there a way for me to find out if it's supported or not?

Re: Vsync doesn't seem to work...

Posted: Wed May 08, 2013 15:10
by Gez
Blue Shadow wrote:
Gez wrote:vid_maxfps isn't implemented in the OpenGL renderer.
Oh! I wasn't aware of that. Why is it not, I wonder? Any specific reason(s)?
I have no idea how to do that, I have not much motivation to look into it, and if you go back to the original feature request thread, Graf was hostile to the idea.
Blue Shadow wrote:
To me, it means that your OpenGL drivers either do not support SetVSync at all (function not present) or they do but it doesn't work.
Not that it matters, now, but is there a way for me to find out if it's supported or not?
Well. If you can compile a custom build, you could look for this code in src/gl/system/gl_interface.cpp:

Code: Select all

#if !defined (unix) && !defined (__APPLE__)
	PFNWGLSWAPINTERVALEXTPROC vs = (PFNWGLSWAPINTERVALEXTPROC)wglGetProcAddress("wglSwapIntervalEXT");
	if (vs) gl->SetVSync = vs;
#endif
Add a line like this after the call to wglGetProcAddress, but before the #endif:

Code: Select all

	Printf("GL proc address for vsync: %x\n", vs");
Then compile, run GZDoom, and look in your console log if the given address is 0 or some non-null hex value.

It might also be indicated somewhere in this utility's various reports, I'm not sure.

Re: Vsync doesn't seem to work...

Posted: Fri May 10, 2013 1:57
by NeuralStunner
I thought windowed mode implied vsync. (In the sense that your desktop runs at target framerate.)

Re: Vsync doesn't seem to work...

Posted: Sat May 11, 2013 23:10
by Blue Shadow
Okay, I've managed to compile a custom GZDoom build with the modification you suggested, Gez - Here is what the console printed:

Code: Select all

GL proc address for vsync: afb23d0
What does that mean?