On Wed, 2011-01-05 at 08:28 -0500, Kristian Høgsberg wrote: > On Tue, Jan 4, 2011 at 11:10 PM, Zhao, Juan J <juan.j.z...@intel.com> wrote: > > Hi all, > > > > In the structure “__DRItexBufferExtensionRec”, we don’t have > > one release interface now. But in our platform, we need to release some > > resources. > > > > Why we don’t need the release interface? Or should we add > > one? > > In the open source drivers, glXBindTexImageEXT is pretty much the same > as glBindTexture. The pixmaps stays bound until you bind another > texture or pixmap, at which point all the resources are released. > There is nothing for the open source drivers to do in release, so the > DRI extension never had a release function. If you need a release > function, just send a patch and we can add it. You'll need to bump > the extension version number and then add the call to release in the > dri loaders (libGL, AIGLX, egl_dri2) conditional on the extension > version. > Thanks a lot! :) I add this interface. Would you please help to check it? > Kristian
-- *^_^* Many thanks & Best Regards SSD-OTC Meego Middleware & TV Team Zhao Juan
From da404aef0ec3e1eba47c4754424020f2484f7510 Mon Sep 17 00:00:00 2001 From: JuanZhao <juan.j.z...@intel.com> Date: Thu, 6 Jan 2011 14:59:43 -0500 Subject: [PATCH] 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 | 12 ++++++++++ src/egl/drivers/dri2/egl_dri2.c | 40 +++++++++++++++++++++++++++++++--- src/glx/dri2_glx.c | 27 +++++++++++++++++++++++ 3 files changed, 75 insertions(+), 4 deletions(-) diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index 9ee039b..84a43ff 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -251,6 +251,18 @@ struct __DRItexBufferExtensionRec { GLint target, GLint format, __DRIdrawable *pDraw); +#if __DRI_TEX_BUFFER_VERSION >=3 + /** + * 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, + GLint format, + __DRIdrawable *pDraw); +#endif }; /** diff --git a/src/egl/drivers/dri2/egl_dri2.c b/src/egl/drivers/dri2/egl_dri2.c index 6f40ab9..1319bd0 100644 --- a/src/egl/drivers/dri2/egl_dri2.c +++ b/src/egl/drivers/dri2/egl_dri2.c @@ -1983,10 +1983,42 @@ 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 format, target; + + ctx = _eglGetCurrentContext(); + dri2_ctx = dri2_egl_context(ctx); + + if (!_eglReleaseTexImage(drv, disp, surf, buffer)) + return EGL_FALSE; + + switch (dri2_surf->base.TextureFormat) { + case EGL_TEXTURE_RGB: + format = __DRI_TEXTURE_FORMAT_RGB; + break; + case EGL_TEXTURE_RGBA: + format = __DRI_TEXTURE_FORMAT_RGBA; + break; + default: + assert(0); + } + + switch (dri2_surf->base.TextureTarget) { + case EGL_TEXTURE_2D: + target = GL_TEXTURE_2D; + break; + default: + assert(0); + } + + (*dri2_dpy->tex_buffer->releaseTexBuffer)(dri2_ctx->dri_context, + target, format, + dri2_surf->dri_drawable); +#endif return EGL_TRUE; } diff --git a/src/glx/dri2_glx.c b/src/glx/dri2_glx.c index b0559b2..f96265b 100644 --- a/src/glx/dri2_glx.c +++ b/src/glx/dri2_glx.c @@ -719,6 +719,33 @@ 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 __DRI2_FLUSH_VERSION >= 3 + if (!pdp->invalidateAvailable && psc->f) + psc->f->invalidate(pdraw->driDrawable); +#endif + + if (psc->texBuffer->base.version >= 3 && + psc->texBuffer->releaseTexBuffer != NULL) { + (*psc->texBuffer->releaseTexBuffer) (pcp->driContext, + pdraw->base.textureTarget, + pdraw->base.textureFormat, + pdraw->driDrawable); + } + } +#endif } static const struct glx_context_vtable dri2_context_vtable = { -- 1.6.1.3
_______________________________________________ mesa-dev mailing list mesa-dev@lists.freedesktop.org http://lists.freedesktop.org/mailman/listinfo/mesa-dev