[cogl] egl-winsys: Bind the framebuffer before swapping



commit dba42715d40ed32596f176a194051c6d78a4c1c0
Author: Neil Roberts <neil linux intel com>
Date:   Mon Dec 5 15:55:12 2011 +0000

    egl-winsys: Bind the framebuffer before swapping
    
    For some reason the EGL spec says that the surface passed to
    eglSwapBuffers must be bound as the current surface for the swap to
    work. Mesa validates that this is the case and returns an error from
    the swap buffers call if not.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=665604
    
    Reviewed-by: Robert Bragg <robert linux intel com>

 cogl/winsys/cogl-winsys-egl.c |   17 +++++++++++++++++
 1 files changed, 17 insertions(+), 0 deletions(-)
---
diff --git a/cogl/winsys/cogl-winsys-egl.c b/cogl/winsys/cogl-winsys-egl.c
index 15d0d7a..c0d7ab9 100644
--- a/cogl/winsys/cogl-winsys-egl.c
+++ b/cogl/winsys/cogl-winsys-egl.c
@@ -1538,6 +1538,14 @@ _cogl_winsys_onscreen_swap_region (CoglOnscreen *onscreen,
       rect[1] = framebuffer_height - rect[1] - rect[3];
     }
 
+  /* At least for eglSwapBuffers the EGL spec says that the surface to
+     swap must be bound to the current context. It looks like Mesa
+     also validates that this is the case for eglSwapBuffersRegion so
+     we must bind here too */
+  _cogl_framebuffer_flush_state (COGL_FRAMEBUFFER (onscreen),
+                                 COGL_FRAMEBUFFER (onscreen),
+                                 COGL_FRAMEBUFFER_STATE_BIND);
+
   if (egl_renderer->pf_eglSwapBuffersRegion (egl_renderer->edpy,
                                              egl_onscreen->egl_surface,
                                              n_rectangles,
@@ -1578,6 +1586,15 @@ _cogl_winsys_onscreen_swap_buffers (CoglOnscreen *onscreen)
                                  &egl_onscreen->kms_onscreen);
   return;
 #else
+  /* The specification for EGL (at least in 1.4) says that the surface
+     needs to be bound to the current context for the swap to work
+     although it may change in future. Mesa explicitly checks for this
+     and just returns an error if this is not the case so we can't
+     just pretend this isn't in the spec. */
+  _cogl_framebuffer_flush_state (COGL_FRAMEBUFFER (onscreen),
+                                 COGL_FRAMEBUFFER (onscreen),
+                                 COGL_FRAMEBUFFER_STATE_BIND);
+
   eglSwapBuffers (egl_renderer->edpy, egl_onscreen->egl_surface);
 #endif
 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]