Merge branch '7.8'
[mesa.git] / src / egl / drivers / dri2 / egl_dri2.c
index 2dfb70de00024833f577144a011e0ac6b8e61b92..4be39627302566baca9ecd0eb1c3d6ff34fa7fb2 100644 (file)
@@ -54,6 +54,8 @@
 struct dri2_egl_driver
 {
    _EGLDriver base;
 struct dri2_egl_driver
 {
    _EGLDriver base;
+
+   void (*glFlush)(void);
 };
 
 struct dri2_egl_display
 };
 
 struct dri2_egl_display
@@ -761,6 +763,7 @@ dri2_initialize(_EGLDriver *drv, _EGLDisplay *disp,
    disp->Extensions.KHR_image_base = EGL_TRUE;
    disp->Extensions.KHR_image_pixmap = EGL_TRUE;
    disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
    disp->Extensions.KHR_image_base = EGL_TRUE;
    disp->Extensions.KHR_image_pixmap = EGL_TRUE;
    disp->Extensions.KHR_gl_renderbuffer_image = EGL_TRUE;
+   disp->Extensions.KHR_gl_texture_2D_image = EGL_TRUE;
 
    /* we're supporting EGL 1.4 */
    *major = 1;
 
    /* we're supporting EGL 1.4 */
    *major = 1;
@@ -874,6 +877,7 @@ static EGLBoolean
 dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
                  _EGLSurface *rsurf, _EGLContext *ctx)
 {
 dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
                  _EGLSurface *rsurf, _EGLContext *ctx)
 {
+   struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_surface *dri2_dsurf = dri2_egl_surface(dsurf);
    struct dri2_egl_surface *dri2_rsurf = dri2_egl_surface(rsurf);
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_surface *dri2_dsurf = dri2_egl_surface(dsurf);
    struct dri2_egl_surface *dri2_rsurf = dri2_egl_surface(rsurf);
@@ -885,6 +889,10 @@ dri2_make_current(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *dsurf,
    if (!_eglBindContext(&ctx, &dsurf, &rsurf))
       return EGL_FALSE;
 
    if (!_eglBindContext(&ctx, &dsurf, &rsurf))
       return EGL_FALSE;
 
+   /* flush before context switch */
+   if (ctx && dri2_drv->glFlush)
+      dri2_drv->glFlush();
+
    ddraw = (dri2_dsurf) ? dri2_dsurf->dri_drawable : NULL;
    rdraw = (dri2_rsurf) ? dri2_rsurf->dri_drawable : NULL;
    cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
    ddraw = (dri2_dsurf) ? dri2_dsurf->dri_drawable : NULL;
    rdraw = (dri2_rsurf) ? dri2_rsurf->dri_drawable : NULL;
    cctx = (dri2_ctx) ? dri2_ctx->dri_context : NULL;
@@ -1012,10 +1020,18 @@ dri2_create_pbuffer_surface(_EGLDriver *drv, _EGLDisplay *disp,
 static EGLBoolean
 dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
 {
 static EGLBoolean
 dri2_swap_buffers(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *draw)
 {
+   struct dri2_egl_driver *dri2_drv = dri2_egl_driver(drv);
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_surface *dri2_surf = dri2_egl_surface(draw);
+   _EGLContext *ctx;
    xcb_dri2_copy_region_cookie_t cookie;
 
    xcb_dri2_copy_region_cookie_t cookie;
 
+   if (dri2_drv->glFlush) {
+      ctx = _eglGetCurrentContext();
+      if (ctx && ctx->DrawSurface == &dri2_surf->base)
+         dri2_drv->glFlush();
+   }
+
    (*dri2_dpy->flush->flush)(dri2_surf->dri_drawable);
 
 #if 0
    (*dri2_dpy->flush->flush)(dri2_surf->dri_drawable);
 
 #if 0
@@ -1353,5 +1369,8 @@ _eglMain(const char *args)
    dri2_drv->base.Name = "DRI2";
    dri2_drv->base.Unload = dri2_unload;
 
    dri2_drv->base.Name = "DRI2";
    dri2_drv->base.Unload = dri2_unload;
 
+   dri2_drv->glFlush =
+      (void (*)(void)) dri2_get_proc_address(&dri2_drv->base, "glFlush");
+
    return &dri2_drv->base;
 }
    return &dri2_drv->base;
 }