From 27d658881fe4cc24890b28d3ee0162469b507665 Mon Sep 17 00:00:00 2001 From: "Juan A. Suarez Romero" Date: Fri, 24 Nov 2017 11:36:19 +0000 Subject: [PATCH] Set swap interval to 0 By default, when swapping front and back frame buffers, this is in sync with v-blank, which prevents tearing. So this means the tests does not run at is maximum allowed speed, but it is restricted somewhat by the attached screen. When running in a window and X realizes the is no monitor attached, the server's Present code will vsync at 1 FPS, which artificially slow down the tests a ton. To avoid this issue, and also because we want to run things as fast as possible, set the swap interval to 0, which basically deactivate the sync. Test: cmake .. -DDEQP_TARGET=x11_egl Change-Id: I04bcb814fb289d58f8788e90f5118db0b7175777 --- framework/egl/egluGLContextFactory.cpp | 2 + .../platform/lnx/X11/tcuLnxX11GlxPlatform.cpp | 44 ++++++++++++++++++++-- framework/platform/win32/tcuWGL.cpp | 13 +++++++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/framework/egl/egluGLContextFactory.cpp b/framework/egl/egluGLContextFactory.cpp index 21d103f..8fbea2a 100644 --- a/framework/egl/egluGLContextFactory.cpp +++ b/framework/egl/egluGLContextFactory.cpp @@ -466,6 +466,8 @@ void RenderContext::create (const NativeDisplayFactory* displayFactory, const Na m_glRenderTarget = tcu::RenderTarget(width, height, pixelFmt, depthBits, stencilBits, numSamples); } + + egl.swapInterval(m_eglDisplay, 0); } void RenderContext::destroy (void) diff --git a/framework/platform/lnx/X11/tcuLnxX11GlxPlatform.cpp b/framework/platform/lnx/X11/tcuLnxX11GlxPlatform.cpp index fd1b2e0..24bb797 100644 --- a/framework/platform/lnx/X11/tcuLnxX11GlxPlatform.cpp +++ b/framework/platform/lnx/X11/tcuLnxX11GlxPlatform.cpp @@ -35,10 +35,15 @@ #define GLX_GLXEXT_PROTOTYPES #include + #ifndef GLX_CONTEXT_OPENGL_NO_ERROR_ARB #define GLX_CONTEXT_OPENGL_NO_ERROR_ARB 0x31B3 #endif +#ifndef PFNGLXSWAPINTERVALMESAPROC +#define PFNGLXSWAPINTERVALMESAPROC PFNGLXSWAPINTERVALSGIPROC +#endif + namespace tcu { namespace lnx @@ -181,6 +186,7 @@ public: virtual void postIterate (void); virtual void makeCurrent (void); void clearCurrent (void); + void swapInterval (int interval); virtual const glw::Functions& getFunctions (void) const; virtual const tcu::RenderTarget& getRenderTarget (void) const; virtual glw::GenericFuncType getProcAddress (const char* name) const; @@ -245,12 +251,17 @@ GlxDisplay::GlxDisplay (EventState& eventState, const char* name) { const int screen = XDefaultScreen(m_display); // nVidia doesn't seem to report client-side extensions correctly, - // so only use server side - const char* const extensions = + // so use also server side + const char* const server_extensions = TCU_CHECK_GLX(glXQueryServerString(m_display, screen, GLX_EXTENSIONS)); - istringstream extStream(extensions); - m_extensions = set(istream_iterator(extStream), + const char* const client_extensions = + TCU_CHECK_GLX(glXQueryExtensionsString(m_display, screen)); + istringstream srvExtStream(server_extensions); + istringstream cliExtStream(client_extensions); + m_extensions = set(istream_iterator(srvExtStream), istream_iterator()); + m_extensions.insert(istream_iterator(cliExtStream), + istream_iterator()); } } @@ -714,6 +725,7 @@ GlxRenderContext::GlxRenderContext (const GlxContextFactory& factory, const GlxFunctionLoader loader; makeCurrent(); glu::initFunctions(&m_functions, &loader, config.type.getAPI()); + swapInterval(0); } GlxRenderContext::~GlxRenderContext (void) @@ -741,6 +753,30 @@ glw::GenericFuncType GlxRenderContext::getProcAddress(const char *name) const return glXGetProcAddress(reinterpret_cast(name)); } +void GlxRenderContext::swapInterval (int interval) +{ + if (m_glxVisual.getGlxDisplay().isGlxExtensionSupported("GLX_EXT_swap_control")) + { + PFNGLXSWAPINTERVALEXTPROC glXSwapIntervalEXT = + reinterpret_cast( + TCU_CHECK_GLX( + glXGetProcAddress( + reinterpret_cast("glXSwapIntervalEXT")))); + + glXSwapIntervalEXT(m_glxVisual.getXDisplay(), m_glxDrawable->getGLXDrawable(), interval); + } + else if (m_glxVisual.getGlxDisplay().isGlxExtensionSupported("GLX_MESA_swap_control")) + { + PFNGLXSWAPINTERVALMESAPROC glXSwapIntervalMESA = + reinterpret_cast( + TCU_CHECK_GLX( + glXGetProcAddress( + reinterpret_cast("glXSwapIntervalMESA")))); + + glXSwapIntervalMESA(interval); + } +} + ContextType GlxRenderContext::getType (void) const { return m_type; diff --git a/framework/platform/win32/tcuWGL.cpp b/framework/platform/win32/tcuWGL.cpp index c36ee94..e871b4c 100644 --- a/framework/platform/win32/tcuWGL.cpp +++ b/framework/platform/win32/tcuWGL.cpp @@ -136,6 +136,9 @@ typedef BOOL (WINAPI* wglChoosePixelFormatARBFunc) (HDC hdc, const int *piAttr typedef HGLRC (WINAPI* wglCreateContextAttribsARBFunc) (HDC hdc, HGLRC hshareContext, const int* attribList); typedef const char* (WINAPI* wglGetExtensionsStringARBFunc) (HDC hdc); +// WGL_EXT_swap_control +typedef BOOL (WINAPI* wglSwapIntervalEXTFunc) (int interval); + DE_END_EXTERN_C namespace tcu @@ -163,6 +166,10 @@ struct Functions wglCreateContextAttribsARBFunc createContextAttribsARB; wglGetExtensionsStringARBFunc getExtensionsStringARB; + // WGL_EXT_swap_control + wglSwapIntervalEXTFunc swapIntervalEXT; + + Functions (void) : createContext (DE_NULL) , deleteContext (DE_NULL) @@ -249,6 +256,9 @@ Library::Library (HINSTANCE instance) m_functions.createContextAttribsARB = (wglCreateContextAttribsARBFunc)m_functions.getProcAddress("wglCreateContextAttribsARB"); m_functions.getExtensionsStringARB = (wglGetExtensionsStringARBFunc)m_functions.getProcAddress("wglGetExtensionsStringARB"); + // WGL_EXT_swap_control + m_functions.swapIntervalEXT = (wglSwapIntervalEXTFunc)m_functions.getProcAddress("wglSwapIntervalEXT"); + m_functions.makeCurrent(tmpWindow.getDeviceContext(), NULL); m_functions.deleteContext(tmpCtx); @@ -525,6 +535,9 @@ Context::Context (const Core* core, wgl.deleteContext(m_context); TCU_THROW(ResourceError, "wglMakeCurrent() failed"); } + + if (core->getLibrary()->isWglExtensionSupported("WGL_EXT_swap_control")) + core->getLibrary()->getFunctions().swapIntervalEXT(0); } Context::~Context (void) -- 2.7.4