st/egl: Add support for EGL_NV_post_sub_buffer
authorFredrik Höglund <fredrik@kde.org>
Wed, 14 Dec 2011 20:24:11 +0000 (21:24 +0100)
committerChia-I Wu <olv@lunarg.com>
Tue, 20 Dec 2011 09:09:06 +0000 (17:09 +0800)
Signed-off-by: Fredrik Höglund <fredrik@kde.org>
[olv: remove #ifdef checks]

src/gallium/state_trackers/egl/common/egl_g3d.c
src/gallium/state_trackers/egl/common/egl_g3d_api.c

index 53811b8fc88a5fc012ee20219f19b6a7d351e530..d147ad00261c5acde002afb01212a3b30afeb249 100644 (file)
@@ -606,11 +606,13 @@ egl_g3d_initialize(_EGLDriver *drv, _EGLDisplay *dpy)
       dpy->Extensions.WL_bind_wayland_display = EGL_TRUE;
 #endif
 
-#ifdef EGL_NOK_swap_region
    if (gdpy->native->get_param(gdpy->native, NATIVE_PARAM_PRESENT_REGION) &&
-       gdpy->native->get_param(gdpy->native, NATIVE_PARAM_PRESERVE_BUFFER))
+       gdpy->native->get_param(gdpy->native, NATIVE_PARAM_PRESERVE_BUFFER)) {
+#ifdef EGL_NOK_swap_region
       dpy->Extensions.NOK_swap_region = EGL_TRUE;
 #endif
+      dpy->Extensions.NV_post_sub_buffer = EGL_TRUE;
+   }
 
    if (egl_g3d_add_configs(drv, dpy, 1) == 1) {
       _eglError(EGL_NOT_INITIALIZED, "eglInitialize(unable to add configs)");
index ed424f9fc110b9e2a3e4a3cb801665260c141116..606e7601f9ad536e2b19e29b4c2db535f2de4708 100644 (file)
@@ -296,6 +296,14 @@ egl_g3d_create_surface(_EGLDriver *drv, _EGLDisplay *dpy, _EGLConfig *conf,
        gconf->stvis.buffer_mask & ST_ATTACHMENT_FRONT_LEFT_MASK)
       gsurf->stvis.render_buffer = ST_ATTACHMENT_FRONT_LEFT;
 
+   if (dpy->Extensions.NV_post_sub_buffer) {
+      if (gsurf->base.Type == EGL_WINDOW_BIT &&
+          gsurf->base.RenderBuffer == EGL_BACK_BUFFER)
+         gsurf->base.PostSubBufferSupportedNV = EGL_TRUE;
+      else
+         gsurf->base.PostSubBufferSupportedNV = EGL_FALSE;
+   }
+
    gsurf->stfbi = egl_g3d_create_st_framebuffer(&gsurf->base);
    if (!gsurf->stfbi) {
       nsurf->destroy(nsurf);
@@ -601,6 +609,16 @@ egl_g3d_swap_buffers_region(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf
 }
 #endif /* EGL_NOK_swap_region */
 
+static EGLBoolean
+egl_g3d_post_sub_buffer(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
+                        EGLint x, EGLint y, EGLint width, EGLint height)
+{
+   /* Note: y=0=bottom */
+   const EGLint rect[4] = { x, surf->Height - y - height, width, height };
+
+   return swap_buffers(drv, dpy, surf, 1, rect, EGL_TRUE);
+}
+
 static EGLBoolean
 egl_g3d_copy_buffers(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
                      EGLNativePixmapType target)
@@ -891,4 +909,6 @@ egl_g3d_init_driver_api(_EGLDriver *drv)
 #ifdef EGL_NOK_swap_region
    drv->API.SwapBuffersRegionNOK = egl_g3d_swap_buffers_region;
 #endif
+
+   drv->API.PostSubBufferNV = egl_g3d_post_sub_buffer;
 }