[Mesa-dev] [PATCH 05/43] dri_interface: Update __DRItexBufferExtensionRec to version 3

Emil Velikov emil.l.velikov at gmail.com
Tue Feb 18 17:19:44 PST 2014


Commit e59fa4c46c8("dri2: release texture image.") updated the extension
without bumping the version number. This commit handles this, adding a
stub for _eglReleaseTexImage() to prevent compilation issues.

Note that with this patch glXReleaseTexImageEXT and eglReleaseTexImage
will use slighly higher CPU usage as up-to now those were empty stubs,
while now the driver implementation will be executed assuming any driver
has one.

Signed-off-by: Emil Velikov <emil.l.velikov at gmail.com>
---
 include/GL/internal/dri_interface.h |  2 +-
 src/egl/drivers/dri2/egl_dri2.c     |  9 +++++----
 src/egl/main/eglsurface.c           | 11 +++++++++++
 src/egl/main/eglsurface.h           |  3 +++
 src/glx/dri2_glx.c                  |  2 --
 src/glx/drisw_glx.c                 |  2 --
 6 files changed, 20 insertions(+), 9 deletions(-)

diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h
index 5c520dc..8821e73 100644
--- a/include/GL/internal/dri_interface.h
+++ b/include/GL/internal/dri_interface.h
@@ -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;
 
diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c
index 892f1f4..2c2a893 100644
--- a/src/egl/drivers/dri2/egl_dri2.c
+++ b/src/egl/drivers/dri2/egl_dri2.c
@@ -1088,7 +1088,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;
@@ -1108,11 +1107,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,
+
+   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);
-#endif
+   }
 
    return EGL_TRUE;
 }
diff --git a/src/egl/main/eglsurface.c b/src/egl/main/eglsurface.c
index 1dca3e0..b97eb7a 100644
--- a/src/egl/main/eglsurface.c
+++ b/src/egl/main/eglsurface.c
@@ -533,6 +533,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,
diff --git a/src/egl/main/eglsurface.h b/src/egl/main/eglsurface.h
index a954123..d13d301 100644
--- a/src/egl/main/eglsurface.h
+++ b/src/egl/main/eglsurface.h
@@ -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);
diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c
index 67fe9c1..1cb0052 100644
--- a/src/glx/dri2_glx.c
+++ b/src/glx/dri2_glx.c
@@ -1032,7 +1032,6 @@ 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);
@@ -1052,7 +1051,6 @@ dri2_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
                                            pdraw->driDrawable);
       }
    }
-#endif
 }
 
 static const struct glx_context_vtable dri2_context_vtable = {
diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c
index 13a4b96..9e49838 100644
--- a/src/glx/drisw_glx.c
+++ b/src/glx/drisw_glx.c
@@ -341,7 +341,6 @@ 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;
    __GLXDRIdrawable *base = GetGLXDRIDrawable(dpy, drawable);
@@ -362,7 +361,6 @@ drisw_release_tex_image(Display * dpy, GLXDrawable drawable, int buffer)
                                            pdraw->driDrawable);
       }
    }
-#endif
 }
 
 static const struct glx_context_vtable drisw_context_vtable = {
-- 
1.9.0



More information about the mesa-dev mailing list