[Spice-devel] [PATCH 04/11] spicec: use doublebuffer for opengl

Marc-André Lureau marcandre.lureau at gmail.com
Tue Sep 24 04:42:15 PDT 2013


This visually reduces glitches without noticeable speed difference.

It's also the traditionnal way of doing opengl.
---
 client/red_window.h          |  2 ++
 client/screen.cpp            |  1 +
 client/x11/platform.cpp      |  2 +-
 client/x11/red_pixmap_gl.cpp |  2 --
 client/x11/red_window.cpp    | 12 ++++++++++++
 5 files changed, 16 insertions(+), 3 deletions(-)

diff --git a/client/red_window.h b/client/red_window.h
index dbd0c79..bf59d8b 100644
--- a/client/red_window.h
+++ b/client/red_window.h
@@ -82,6 +82,8 @@ public:
 
     void set_type_gl();
     void unset_type_gl();
+
+    void swap_gl();
 #endif
 
     int get_screen_num();
diff --git a/client/screen.cpp b/client/screen.cpp
index a05d562..e76fd50 100644
--- a/client/screen.cpp
+++ b/client/screen.cpp
@@ -357,6 +357,7 @@ inline void RedScreen::update_done()
         }
         layer->on_update_completion(_update_mark - 1);
     }
+    _window.swap_gl();
 }
 
 inline void RedScreen::update_composit(QRegion& composit_rgn)
diff --git a/client/x11/platform.cpp b/client/x11/platform.cpp
index da6b634..475ee6a 100644
--- a/client/x11/platform.cpp
+++ b/client/x11/platform.cpp
@@ -3224,7 +3224,7 @@ void Platform::init()
         int num_configs;
         int attrlist[] = {
             GLX_RENDER_TYPE, GLX_RGBA_BIT,
-            GLX_DOUBLEBUFFER, False,
+            GLX_DOUBLEBUFFER, True,
             GLX_DRAWABLE_TYPE, GLX_PBUFFER_BIT | GLX_WINDOW_BIT,
             GLX_X_VISUAL_TYPE, GLX_TRUE_COLOR,
             GLX_RED_SIZE, 8,
diff --git a/client/x11/red_pixmap_gl.cpp b/client/x11/red_pixmap_gl.cpp
index 693b67d..1a58628 100644
--- a/client/x11/red_pixmap_gl.cpp
+++ b/client/x11/red_pixmap_gl.cpp
@@ -79,8 +79,6 @@ RedPixmapGL::RedPixmapGL(int width, int height, RedDrawable::Format format,
             glXDestroyContext(XPlatform::get_display(), _glcont);
             THROW("no GL_EXT_framebuffer_object extension");
         }
-        glDrawBuffer(GL_FRONT);
-        glReadBuffer(GL_FRONT);
 
         glGenTextures(1, &tex);
         glBindTexture(GL_TEXTURE_2D, tex);
diff --git a/client/x11/red_window.cpp b/client/x11/red_window.cpp
index 83144a5..b6e11e1 100644
--- a/client/x11/red_window.cpp
+++ b/client/x11/red_window.cpp
@@ -2122,6 +2122,18 @@ void RedWindow::untouch_context()
     glXMakeCurrent(x_display, 0, 0);
 }
 
+void RedWindow::swap_gl()
+{
+    PixelsSource_p *pix_source = (PixelsSource_p*)get_opaque();
+    RedGlContext context = pix_source->x_drawable.context;
+
+    if (!context)
+        return;
+
+    glXMakeCurrent(x_display, get_window(), context);
+    glXSwapBuffers(x_display, get_window());
+}
+
 void RedWindow::set_type_gl()
 {
     PixelsSource_p *pix_source = (PixelsSource_p*)get_opaque();
-- 
1.8.3.1



More information about the Spice-devel mailing list