dri_interface: Update __DRItexBufferExtensionRec to version 3
authorEmil Velikov <emil.l.velikov@gmail.com>
Tue, 18 Feb 2014 03:04:03 +0000 (03:04 +0000)
committerEmil Velikov <emil.l.velikov@gmail.com>
Mon, 28 Apr 2014 18:11:27 +0000 (19:11 +0100)
With commit e59fa4c46c8("dri2: release texture image.") we updated the
extension without bumping the version number. The patch itself added an
interface required to enable texture_from_pixmap on certain platforms.

The new code was effectively never build, as it depended on
__DRI_TEX_BUFFER_VERSION >= 3, which never came to be in upstream mesa.

This commit bumps the version number, drops the __DRI_TEX_BUFFER_VERSION
checks and resolves all the build conflicts. Additionally it add a version
check as egl and dri3, as require version 2 of the extension which does
not have the releaseTexBuffer hook.

Cc: Juan Zhao <juan.j.zhao@intel.com>
Cc: Kristian Høgsberg <krh@bitplanet.net>
Signed-off-by: Emil Velikov <emil.l.velikov@gmail.com>
Reviewed-by: Ian Romanick <ian.d.romanick@intel.com>
Reviewed-by: Kristian Høgsberg <krh@bitplanet.net>
include/GL/internal/dri_interface.h
src/egl/drivers/dri2/egl_dri2.c
src/egl/main/eglsurface.c
src/egl/main/eglsurface.h
src/glx/dri2_glx.c
src/glx/dri3_glx.c
src/glx/drisw_glx.c

index d028d05089416be2e886199235c4d839a5772682..4d57d0b824737852090fa51ece67875cd4d77407 100644 (file)
@@ -231,7 +231,7 @@ struct __DRItexOffsetExtensionRec {
 #define __DRI_TEXTURE_FORMAT_RGBA        0x20DA
 
 #define __DRI_TEX_BUFFER "DRI_TexBuffer"
-#define __DRI_TEX_BUFFER_VERSION 2
+#define __DRI_TEX_BUFFER_VERSION 3
 struct __DRItexBufferExtensionRec {
     __DRIextension base;
 
index a132964ea2188da019f6e66223f5032e4ef088ff..81a354236f4bf6f38653f712e2aa479b2a75151e 100644 (file)
@@ -1189,7 +1189,6 @@ static EGLBoolean
 dri2_release_tex_image(_EGLDriver *drv,
                       _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer)
 {
-#if __DRI_TEX_BUFFER_VERSION >= 3
    struct dri2_egl_display *dri2_dpy = dri2_egl_display(disp);
    struct dri2_egl_surface *dri2_surf = dri2_egl_surface(surf);
    struct dri2_egl_context *dri2_ctx;
@@ -1209,11 +1208,13 @@ dri2_release_tex_image(_EGLDriver *drv,
    default:
       assert(0);
    }
-   if (dri2_dpy->tex_buffer->releaseTexBuffer!=NULL)
-    (*dri2_dpy->tex_buffer->releaseTexBuffer)(dri2_ctx->dri_context,
-                                             target,
-                                             dri2_surf->dri_drawable);
-#endif
+
+   if (dri2_dpy->tex_buffer->base.version >= 3 &&
+       dri2_dpy->tex_buffer->releaseTexBuffer != NULL) {
+      (*dri2_dpy->tex_buffer->releaseTexBuffer)(dri2_ctx->dri_context,
+                                                target,
+                                                dri2_surf->dri_drawable);
+   }
 
    return EGL_TRUE;
 }
index c5ea2245b3d41e7df2b52735f5cf48535c8fcc74..e2cb73b7e9123a44b38917dc9807b1e412e6b3fd 100644 (file)
@@ -531,6 +531,17 @@ _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surface,
    return EGL_TRUE;
 }
 
+EGLBoolean
+_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf,
+                    EGLint buffer)
+{
+   /* TODO: do basic error checking and return success/fail.
+    * Drivers must implement the real stuff.
+    */
+
+  return EGL_TRUE;
+}
+
 
 EGLBoolean
 _eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf,
index a9541239701b77e4c5468af4a73051cf96f707c2..d13d301f64323d25499e0467bad9eabaa8f7ea6f 100644 (file)
@@ -94,6 +94,9 @@ _eglSurfaceAttrib(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint a
 PUBLIC extern EGLBoolean
 _eglBindTexImage(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint buffer);
 
+PUBLIC extern EGLBoolean
+_eglReleaseTexImage(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer);
+
 
 extern EGLBoolean
 _eglSwapInterval(_EGLDriver *drv, _EGLDisplay *dpy, _EGLSurface *surf, EGLint interval);
index 79f6ecc99336a11804248c98983eaace6c6884b0..496590812213c2cfa3e2274e68e4b01c214ec8b5 100644 (file)
@@ -1032,17 +1032,14 @@ dri2_bind_tex_image(Display * dpy,
 static void
 dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
 {
-#if __DRI_TEX_BUFFER_VERSION >= 3
    struct glx_context *gc = __glXGetCurrentContext();
    struct dri2_context *pcp = (struct dri2_context *) gc;
    __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
    struct glx_display *dpyPriv = __glXInitialize(dpy);
    struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
-   struct dri2_display *pdp =
-      (struct dri2_display *) dpyPriv->dri2Display;
    struct dri2_screen *psc;
 
-   if (pdraw != NULL) {
+   if (dpyPriv != NULL && pdraw != NULL) {
       psc = (struct dri2_screen *) base->psc;
 
       if (psc->texBuffer->base.version >= 3 &&
@@ -1052,7 +1049,6 @@ dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
                                            pdraw->driDrawable);
       }
    }
-#endif
 }
 
 static const struct glx_context_vtable dri2_context_vtable = {
index b7dac8e67b5632bc0b24de3f5b2a4859e2073908..653b1e5c5f617b93660172fe828a89a2f6b9b956 100644 (file)
@@ -1527,7 +1527,8 @@ dri3_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
    if (pdraw != NULL) {
       psc = (struct dri3_screen *) base->psc;
 
-      if (psc->texBuffer->releaseTexBuffer)
+      if (psc->texBuffer->base.version >= 3 &&
+          psc->texBuffer->releaseTexBuffer != NULL)
          (*psc->texBuffer->releaseTexBuffer) (pcp->driContext,
                                               pdraw->base.textureTarget,
                                               pdraw->driDrawable);
index 33d347a6e169e1ac9e4a0e3b8e2981fc61a269f0..a77be4e429ac8fbfd9a59d096cb394a1be1e1004 100644 (file)
@@ -342,16 +342,15 @@ drisw_bind_tex_image(Display * dpy,
 static void
 drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
 {
-#if __DRI_TEX_BUFFER_VERSION >= 3
    struct glx_context *gc = __glXGetCurrentContext();
-   struct dri2_context *pcp = (struct dri2_context *) gc;
+   struct drisw_context *pcp = (struct drisw_context *) gc;
    __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
    struct glx_display *dpyPriv = __glXInitialize(dpy);
-   struct dri2_drawable *pdraw = (struct dri2_drawable *) base;
-   struct dri2_screen *psc;
+   struct drisw_drawable *pdraw = (struct drisw_drawable *) base;
+   struct drisw_screen *psc;
 
-   if (pdraw != NULL) {
-      psc = (struct dri2_screen *) base->psc;
+   if (dpyPriv != NULL && pdraw != NULL) {
+      psc = (struct drisw_screen *) base->psc;
 
       if (!psc->texBuffer)
          return;
@@ -363,7 +362,6 @@ drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
                                            pdraw->driDrawable);
       }
    }
-#endif
 }
 
 static const struct glx_context_vtable drisw_context_vtable = {