Module: Mesa Branch: master Commit: e59fa4c46c8857f2e04447777dd197464c95b2cb URL: http://cgit.freedesktop.org/mesa/mesa/commit/?id=e59fa4c46c8857f2e04447777dd197464c95b2cb
Author: Juan Zhao <juan.j.z...@intel.com> Date: Sun Jan 9 12:03:02 2011 -0500 dri2: release texture image. Add release function for texture_from_pixmap extension. Some platform need to release texture image for texture_from_pixmap extension, add this interface for those platforms. --- include/GL/internal/dri_interface.h | 9 +++++++++ src/egl/drivers/dri2/egl_dri2.c | 29 +++++++++++++++++++++++++---- src/glx/dri2_glx.c | 21 +++++++++++++++++++++ 3 files changed, 55 insertions(+), 4 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 9ee039b..39aa68b 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -251,6 +251,15 @@ struct __DRItexBufferExtensionRec { GLint target, GLint format, __DRIdrawable *pDraw); + /** + * Method to release texture buffer in case some special platform + * need this. + * + * For GLX_EXT_texture_from_pixmap with AIGLX. + */ + void (*releaseTexBuffer)(__DRIcontext *pDRICtx, + GLint target, + __DRIdrawable *pDraw); }; /** diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 6f40ab9..7592984 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1983,10 +1983,31 @@ static EGLBoolean dri2_release_tex_image(_EGLDriver *drv, _EGLDisplay *disp, _EGLSurface *surf, EGLint buffer) { - (void) drv; - (void) disp; - (void) surf; - (void) 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; + _EGLContext *ctx; + GLint target; + + ctx = _eglGetCurrentContext(); + dri2_ctx = dri2_egl_context(ctx); + + if (!_eglReleaseTexImage(drv, disp, surf, buffer)) + return EGL_FALSE; + + switch (dri2_surf->base.TextureTarget) { + case EGL_TEXTURE_2D: + target = GL_TEXTURE_2D; + break; + 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 return EGL_TRUE; } diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index b0559b2..75b1a10 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -719,6 +719,27 @@ 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) { + psc = (struct dri2_screen *) base->psc; + + if (psc->texBuffer->base.version >= 3 && + psc->texBuffer->releaseTexBuffer != NULL) { + (*psc->texBuffer->releaseTexBuffer) (pcp->driContext, + pdraw->base.textureTarget, + pdraw->driDrawable); + } + } +#endif } static const struct glx_context_vtable dri2_context_vtable = { _______________________________________________ mesa-commit mailing list mesa-commit@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-commit