Page 1 of 1

Vsync Is Absent in 2.3.2

Posted: Sun Feb 26, 2017 1:47
by blueinferno776
Vsync does not work with the current release or any of the unofficial builds when turned on. I can only get it to work when I force it on in radeon settings but it seems to slow gzdoom down by a lot.

This really is persisting through every 2.4.0 git build too. I waited to see if someone else has had this problem but now it clear that I needed to say something about it now.

Re: Vsync Is Absent in 2.3.2

Posted: Sun Feb 26, 2017 5:59
by dpJudas
Mind try downloading a nightly build of QZDoom? Boot it in software mode, go to "Options->Change Rendering Output" and switch "Software Canvas" to OpenGL, and then restart QZDoom once again. Then check if vsync is working there.

It will be useful for me to know if that is the case or not. If it works in QZDoom's OpenGL software canvas, then I have a good theory on what might be broken in GZDoom.

@Graf: The OpenGLFrameBuffer class in GZDoom might need the following code from OpenGLSWFrameBuffer::SetVSync:

Code: Select all

void OpenGLSWFrameBuffer::SetVSync(bool vsync)
	// Switch to the default frame buffer because Nvidia's driver associates the vsync state with the bound FB object.
	GLint oldDrawFramebufferBinding = 0, oldReadFramebufferBinding = 0;
	glGetIntegerv(GL_DRAW_FRAMEBUFFER_BINDING, &oldDrawFramebufferBinding);
	glGetIntegerv(GL_READ_FRAMEBUFFER_BINDING, &oldReadFramebufferBinding);
	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, 0);
	glBindFramebuffer(GL_READ_FRAMEBUFFER, 0);


	glBindFramebuffer(GL_DRAW_FRAMEBUFFER, oldDrawFramebufferBinding);
	glBindFramebuffer(GL_READ_FRAMEBUFFER, oldReadFramebufferBinding);
I'm not 100% sure if the default FB is bound in GZDoom when vid_vsync is changed. If it isn't, bad things might happen.

Re: Vsync Is Absent in 2.3.2

Posted: Sun Feb 26, 2017 6:34
by blueinferno776
Vsync works perfect with QZdooms opengl render canvas. GZdoom just outright ignores the vsync option.

Re: Vsync Is Absent in 2.3.2

Posted: Sun Feb 26, 2017 7:44
by dpJudas
Thanks for testing. Adding the code from my previous post to GZDoom will probably fix it then.

Re: Vsync Is Absent in 2.3.2

Posted: Sun Feb 26, 2017 13:49
by Graf Zahl
Can you make a pull request?

Also, what hardware was this problem on? It works fine for me on a Geforce 550ti.

Re: Vsync Is Absent in 2.3.2

Posted: Sun Feb 26, 2017 14:22
by dpJudas
Okay, I'll create a pull request with it a little later today.

Originally I experienced a vsync problem on some Nvidia cards when I added the render buffer stuff. Back then, I managed to make it stop by firing off a vsync (wglSetInterval or whatever its called) call before creating any frame buffer objects. When I then much later ported Randi's D3D9 FB to OpenGL the problem resurfaced for me. This time because the code there has the frame buffer object bound when the vid_vsync custom CVAR fires.

While all that was for Nvidia here we have an AMD card showing similar kind of behavior. So my guess is that it is very important to make sure wglSetInterval and wglSwapBuffers calls are only executed when the default frame buffer object is bound. Since blueinferno776 is not seeing the problem with OpenGLSWFrameBuffer I think there is a fair chance this will fix his vsync issue.