=== modified file 'plugins/opengl/CMakeLists.txt' --- plugins/opengl/CMakeLists.txt 2012-12-12 07:33:12 +0000 +++ plugins/opengl/CMakeLists.txt 2013-12-11 17:21:33 +0000 @@ -21,7 +21,7 @@ else (USE_GLES) find_package (OpenGL) if (OPENGL_FOUND) - compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${OPENGL_gl_LIBRARY} ${INTERNAL_LIBRARIES} dl INCDIRS ${OPENGL_INCLUDE_DIR}) + compiz_plugin(opengl PLUGINDEPS composite LIBRARIES ${X11_Xext_LIB} ${OPENGL_gl_LIBRARY} ${INTERNAL_LIBRARIES} dl INCDIRS ${X11_XSync_INCLUDE_PATH} ${OPENGL_INCLUDE_DIR}) endif (OPENGL_FOUND) endif (USE_GLES) === modified file 'plugins/opengl/include/opengl/opengl.h' --- plugins/opengl/include/opengl/opengl.h 2013-04-27 23:30:28 +0000 +++ plugins/opengl/include/opengl/opengl.h 2013-12-23 21:51:10 +0000 @@ -37,6 +37,7 @@ #else #include #include +#include /* Some implementations have not yet given a definition * to GLX_BACK_BUFFER_AGE_EXT but this is the token as defined @@ -117,6 +118,26 @@ #define GLX_FRONT_LEFT_EXT 0x20DE #endif +#ifndef GL_ARB_sync +typedef struct __GLsync *GLsync; +typedef int64_t GLint64; +typedef uint64_t GLuint64; +typedef intptr_t GLintptr; + +#define GL_TIMEOUT_IGNORED 0xFFFFFFFFFFFFFFFFull +#define GL_ALREADY_SIGNALED 0x911A +#define GL_TIMEOUT_EXPIRED 0x911B +#define GL_CONDITION_SATISFIED 0x911C +#define GL_WAIT_FAILED 0x911D +#define GL_SYNC_GPU_COMMANDS_COMPLETE 0x9117 +#define GL_SYNC_STATUS 0x9114 +#define GL_SIGNALED 0x9119 +#endif + +#ifndef GL_EXT_x11_sync_object +#define GL_SYNC_X11_FENCE_EXT 0x90E1 +#endif + namespace GL { #ifdef USE_GLES typedef EGLImageKHR (*EGLCreateImageKHRProc) (EGLDisplay dpy, @@ -204,6 +225,24 @@ int *params); #endif + typedef GLsync (*GLFenceSyncProc) (GLenum condition, GLbitfield flags); + typedef void (*GLDeleteSyncProc) (GLsync sync); + typedef GLenum (*GLClientWaitSyncProc) (GLsync sync, + GLbitfield flags, + GLuint64 timeout); + typedef void (*GLWaitSyncProc) (GLsync sync, + GLbitfield flags, + GLuint64 timeout); + typedef void (*GLGetSyncivProc) (GLsync sync, + GLenum pname, + GLsizei bufSize, + GLsizei *length, + GLint *values); + + typedef GLsync (*GLImportSyncProc) (GLenum external_sync_type, + GLintptr external_sync, + GLbitfield flags); + typedef void (*GLActiveTextureProc) (GLenum texture); typedef void (*GLClientActiveTextureProc) (GLenum texture); typedef void (*GLMultiTexCoord2fProc) (GLenum, GLfloat, GLfloat); @@ -519,6 +558,14 @@ #endif + extern GLFenceSyncProc fenceSync; + extern GLDeleteSyncProc deleteSync; + extern GLClientWaitSyncProc clientWaitSync; + extern GLWaitSyncProc waitSync; + extern GLGetSyncivProc getSynciv; + + extern GLImportSyncProc importSync; + extern bool textureFromPixmap; extern bool textureRectangle; extern bool textureNonPowerOfTwo; @@ -538,6 +585,9 @@ extern GLint maxTextureUnits; extern bool bufferAge; + extern bool sync; + extern bool xToGLSync; + extern bool canDoSaturated; extern bool canDoSlightlySaturated; === added file 'plugins/opengl/include/opengl/xtoglsync.h' --- plugins/opengl/include/opengl/xtoglsync.h 1970-01-01 00:00:00 +0000 +++ plugins/opengl/include/opengl/xtoglsync.h 2013-12-23 21:06:51 +0000 @@ -0,0 +1,97 @@ +/* + * Copyright © 2011 NVIDIA Corporation + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of + * NVIDIA Corporation not be used in advertising or publicity pertaining to + * distribution of the software without specific, written prior permission. + * NVIDIA Corporation makes no representations about the suitability of this + * software for any purpose. It is provided "as is" without express or + * implied warranty. + * + * NVIDIA CORPORATION DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL NVIDIA CORPORATION BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION + * WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: James Jones + */ + +#ifndef _GLXTOGLSYNC_H +#define _GLXTOGLSYNC_H + +#include +#include +#include + +/** + * Class that manages an XFenceSync wrapped in a GLsync object. + * + * Can be used to synchronize operations in the GL command stream + * with operations in the X command stream. + */ +class XToGLSync { + public: + XToGLSync(); + ~XToGLSync(); + + XSyncAlarm alarm(void) const { return a; } + bool isReady(void) const { return state == XTOGLS_READY; } + + /** + * Sends the trigger request to the server. The fence will be signaled + * after all rendering has completed. + */ + void trigger(void); + + /** + * Calls glWaitSync. Any OpenGL commands after this will wait for the + * fence to be signaled. + */ + void insertWait(void); + + /** + * Blocks until the fence is signaled, or until a timeout expires. + * + * \param The maximum time to wait, in nanoseconds. + * \return One of \c GL_ALREADY_SIGNALED, \c GL_CONDITION_SATISFIED, + * \c GL_TIMEOUT_EXPIRED, or \c GL_WAIT_FAILED. + */ + GLenum checkUpdateFinished(GLuint64 timeout); + + /** + * Resets the fence. + */ + void reset(void); + void handleEvent(XSyncAlarmNotifyEvent *ev); + + private: + XSyncFence f; + GLsync fGL; + + XSyncCounter c; + XSyncAlarm a; + XSyncValue nextCounterValue; + + enum { + XTOGLS_READY, + XTOGLS_TRIGGER_SENT, + XTOGLS_WAITING, + XTOGLS_DONE, + XTOGLS_RESET_PENDING, + } state; + + static bool syncValuesInitialized; + static XSyncValue zero; + static XSyncValue one; + + static Bool alarmEventPredicate(Display *dpy, XEvent *ev, XPointer arg); +}; + +#endif === modified file 'plugins/opengl/opengl.xml.in' --- plugins/opengl/opengl.xml.in 2012-12-17 10:53:59 +0000 +++ plugins/opengl/opengl.xml.in 2013-12-18 21:20:48 +0000 @@ -59,6 +59,11 @@ <_long>Use glXSwapBuffers to display every frame. This eliminates visible tearing with most drivers and dramatically improves visual smoothness. Automatically enabled when framebuffer_object is on. true +