[client] fixed incorrect usage of glXWaitVideoSyncSGI

This commit is contained in:
Geoffrey McRae 2017-12-11 07:14:43 +11:00
parent 7574e03d86
commit 5863160c69

View File

@ -18,7 +18,6 @@
static PFNGLXGETVIDEOSYNCSGIPROC glXGetVideoSyncSGI = NULL; static PFNGLXGETVIDEOSYNCSGIPROC glXGetVideoSyncSGI = NULL;
static PFNGLXWAITVIDEOSYNCSGIPROC glXWaitVideoSyncSGI = NULL; static PFNGLXWAITVIDEOSYNCSGIPROC glXWaitVideoSyncSGI = NULL;
static PFNGLXSWAPINTERVALSGIPROC glXSwapIntervalSGI = NULL;
struct LGR_OpenGL struct LGR_OpenGL
{ {
@ -100,9 +99,8 @@ bool lgr_opengl_initialize(void ** opaque, const LG_RendererParams params, const
{ {
glXGetVideoSyncSGI = (PFNGLXGETVIDEOSYNCSGIPROC )glXGetProcAddress((const GLubyte *)"glXGetVideoSyncSGI" ); glXGetVideoSyncSGI = (PFNGLXGETVIDEOSYNCSGIPROC )glXGetProcAddress((const GLubyte *)"glXGetVideoSyncSGI" );
glXWaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC)glXGetProcAddress((const GLubyte *)"glXWaitVideoSyncSGI"); glXWaitVideoSyncSGI = (PFNGLXWAITVIDEOSYNCSGIPROC)glXGetProcAddress((const GLubyte *)"glXWaitVideoSyncSGI");
glXSwapIntervalSGI = (PFNGLXSWAPINTERVALSGIPROC )glXGetProcAddress((const GLubyte *)"glXSwapIntervalSGI" );
if (!glXGetVideoSyncSGI || !glXWaitVideoSyncSGI || !glXSwapIntervalSGI) if (!glXGetVideoSyncSGI || !glXWaitVideoSyncSGI)
{ {
glXGetVideoSyncSGI = NULL; glXGetVideoSyncSGI = NULL;
DEBUG_ERROR("Failed to get proc addresses"); DEBUG_ERROR("Failed to get proc addresses");
@ -212,6 +210,7 @@ bool lgr_opengl_initialize(void ** opaque, const LG_RendererParams params, const
this->resizeWindow = true; this->resizeWindow = true;
this->drawStart = nanotime(); this->drawStart = nanotime();
glXGetVideoSyncSGI(&this->gpuFrameCount);
// copy the format into the local storage // copy the format into the local storage
memcpy(&this->format, &format, sizeof(LG_RendererFormat)); memcpy(&this->format, &format, sizeof(LG_RendererFormat));
@ -427,14 +426,7 @@ bool lgr_opengl_render(void * opaque, const uint8_t * data, bool resample)
// wait until the frame has been presented, this is to avoid the video card // wait until the frame has been presented, this is to avoid the video card
// buffering frames, we would rather skip a frame then fall behind the guest // buffering frames, we would rather skip a frame then fall behind the guest
uint count; glXWaitVideoSyncSGI(1, 0, &this->gpuFrameCount);
glXGetVideoSyncSGI(&count);
if (this->gpuFrameCount == count)
{
uint remainder;
glXWaitVideoSyncSGI(count, 1, &remainder);
}
this->gpuFrameCount = count + 1;
const uint64_t t = nanotime(); const uint64_t t = nanotime();
this->renderTime += t - this->lastFrameTime; this->renderTime += t - this->lastFrameTime;