From 7ace7cfba43427fc09dec23ac94b5c2b663d58ff Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 19 May 2007 08:28:07 -0600 Subject: added texture_from_pixmap functions --- include/GL/xmesa.h | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/GL/xmesa.h b/include/GL/xmesa.h index f185a15cdb..2199b08cf0 100644 --- a/include/GL/xmesa.h +++ b/include/GL/xmesa.h @@ -1,8 +1,8 @@ /* * Mesa 3-D graphics library - * Version: 4.1 + * Version: 7.1 * - * Copyright (C) 1999-2002 Brian Paul All Rights Reserved. + * Copyright (C) 1999-2007 Brian Paul All Rights Reserved. * * Permission is hereby granted, free of charge, to any person obtaining a * copy of this software and associated documentation files (the "Software"), @@ -397,6 +397,25 @@ extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap, +/* + * Texture from Pixmap + * New in Mesa 7.1 + */ +extern void +XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer, + const int *attrib_list); + +extern void +XMesaReleaseTexImage(Display *dpy, XMesaBuffer drawable, int buffer); + + +extern XMesaBuffer +XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p, + XMesaColormap cmap, + int format, int target, int mipmap); + + + #ifdef __cplusplus } #endif -- cgit v1.2.3 From 74519c42311c67a2f914768abbe905d321702386 Mon Sep 17 00:00:00 2001 From: Brian Date: Sat, 19 May 2007 08:56:15 -0600 Subject: Disable (at least for now) PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC typedef. If an app (like progs/samples/blendxor.c) includes both gl.h and glext.h this typedef will get hit in both headers, causing an error. Possibly work around by bringing GL_NV_geometry_program4 items into gl.h. --- include/GL/gl.h | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'include') diff --git a/include/GL/gl.h b/include/GL/gl.h index 6e92481a53..a388de36e4 100644 --- a/include/GL/gl.h +++ b/include/GL/gl.h @@ -2221,8 +2221,13 @@ GLAPI void APIENTRY glFramebufferTextureLayerEXT(GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); #endif /* GL_GLEXT_PROTOTYPES */ +#if 0 +/* (temporarily) disabled because of collision with typedef in glext.h + * that happens if apps include both gl.h and glext.h + */ typedef void (APIENTRYP PFNGLFRAMEBUFFERTEXTURELAYEREXTPROC) (GLenum target, GLenum attachment, GLuint texture, GLint level, GLint layer); +#endif #define GL_TEXTURE_1D_ARRAY_EXT 0x8C18 #define GL_PROXY_TEXTURE_1D_ARRAY_EXT 0x8C19 -- cgit v1.2.3 From 24d965fab52f790188e5de6e67e7387809b1f145 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 22 May 2007 13:56:30 +0200 Subject: Fix xserver build after recent XMesa changes. Only build tested. --- include/GL/xmesa.h | 4 ++-- include/GL/xmesa_x.h | 1 + include/GL/xmesa_xf86.h | 29 ++++++++++++++++++++++++++++- src/mesa/drivers/x11/xm_api.c | 20 ++++++++++---------- src/mesa/drivers/x11/xm_image.h | 7 ------- 5 files changed, 41 insertions(+), 20 deletions(-) (limited to 'include') diff --git a/include/GL/xmesa.h b/include/GL/xmesa.h index 2199b08cf0..98139af833 100644 --- a/include/GL/xmesa.h +++ b/include/GL/xmesa.h @@ -402,11 +402,11 @@ extern XMesaBuffer XMesaCreatePBuffer(XMesaVisual v, XMesaColormap cmap, * New in Mesa 7.1 */ extern void -XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer, +XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer, const int *attrib_list); extern void -XMesaReleaseTexImage(Display *dpy, XMesaBuffer drawable, int buffer); +XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer); extern XMesaBuffer diff --git a/include/GL/xmesa_x.h b/include/GL/xmesa_x.h index 721d8b5107..865bab4313 100644 --- a/include/GL/xmesa_x.h +++ b/include/GL/xmesa_x.h @@ -66,6 +66,7 @@ typedef XColor XMesaColor; #define XMesaDrawPoints XDrawPoints #define XMesaDrawLine XDrawLine #define XMesaFillRectangle XFillRectangle +#define XMesaGetImage XGetImage #define XMesaPutImage XPutImage #define XMesaCopyArea XCopyArea diff --git a/include/GL/xmesa_xf86.h b/include/GL/xmesa_xf86.h index 0a15110f65..18908a133f 100644 --- a/include/GL/xmesa_xf86.h +++ b/include/GL/xmesa_xf86.h @@ -42,8 +42,15 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #include "scrnintstr.h" #include "pixmapstr.h" #include "gcstruct.h" +#include "servermd.h" -typedef struct _XMesaImageRec XMesaImage; + +typedef struct _XMesaImageRec { + int width, height; + char *data; + int bytes_per_line; /* Padded to 32 bits */ + int bits_per_pixel; +} XMesaImage; typedef ScreenRec XMesaDisplay; typedef PixmapPtr XMesaPixmap; @@ -120,6 +127,26 @@ do { \ (*__gc->ops->PolyFillRect)((DrawablePtr)__b, __gc, 1, __r); \ } while (0) +static _X_INLINE XMesaImage *XMesaGetImage(XMesaDisplay *dpy, PixmapPtr p, int x, + int y, unsigned int width, + unsigned int height, + unsigned long plane_mask, int format) +{ + XMesaImage *img = Xcalloc(sizeof(*img)); + + img->width = p->drawable.width; + img->height = p->drawable.height; + img->bits_per_pixel = p->drawable.bitsPerPixel; + img->bytes_per_line = PixmapBytePad(width, p->drawable.depth); + img->data = malloc(height * img->bytes_per_line); + + /* Assumes: Images are always in ZPixmap format */ + (*p->drawable.pScreen->GetImage)(&p->drawable, x, y, width, height, + plane_mask, ZPixmap, img->data); + + return img; +} + #define XMesaPutImage(__d,__b,__gc,__i,__sx,__sy,__x,__y,__w,__h) \ do { \ /* Assumes: Images are always in ZPixmap format */ \ diff --git a/src/mesa/drivers/x11/xm_api.c b/src/mesa/drivers/x11/xm_api.c index edaa71508f..cff64d17ad 100644 --- a/src/mesa/drivers/x11/xm_api.c +++ b/src/mesa/drivers/x11/xm_api.c @@ -63,6 +63,7 @@ #endif #include "glxheader.h" +#include "GL/glxtokens.h" #include "GL/xmesa.h" #include "xmesaP.h" #include "context.h" @@ -293,11 +294,9 @@ static GLboolean window_exists( XMesaDisplay *dpy, Window win ) XSetErrorHandler(old_handler); return WindowExistsFlag; } -#endif - static Status -get_drawable_size(Display *dpy, Drawable d, GLuint *width, GLuint *height) +get_drawable_size( XMesaDisplay *dpy, Drawable d, GLuint *width, GLuint *height ) { Window root; Status stat; @@ -308,6 +307,7 @@ get_drawable_size(Display *dpy, Drawable d, GLuint *width, GLuint *height) *height = h; return stat; } +#endif /** @@ -1703,7 +1703,7 @@ XMesaCreatePixmapTextureBuffer(XMesaVisual v, XMesaPixmap p, return NULL; /* get pixmap size, update framebuffer/renderbuffer dims */ - get_drawable_size(v->display, p, &width, &height); + xmesa_get_window_size(v->display, b, &width, &height); _mesa_resize_framebuffer(NULL, &(b->mesa_buffer), width, height); if (target == 0) { @@ -2363,7 +2363,7 @@ xbuffer_to_renderbuffer(int buffer) PUBLIC void -XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer, +XMesaBindTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer, const int *attrib_list) { #if 0 @@ -2375,7 +2375,7 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer, struct gl_renderbuffer *rb; struct xmesa_renderbuffer *xrb; GLint b; - XMesaImage *img; + XMesaImage *img = NULL; GLboolean freeImg = GL_FALSE; b = xbuffer_to_renderbuffer(buffer); @@ -2412,15 +2412,15 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer, * The following is a quick and simple way to implement * BindTexImage. The better way is to write some new FetchTexel() * functions which would extract texels from XImages. We'd still - * need to use XGetImage when texturing from a Pixmap (front buffer) + * need to use GetImage when texturing from a Pixmap (front buffer) * but texturing from a back buffer (XImage) would avoid an image * copy. */ /* get XImage */ if (xrb->pixmap) { - img = XGetImage(dpy, xrb->pixmap, 0, 0, rb->Width, rb->Height, - AllPlanes, ZPixmap ); + img = XMesaGetImage(dpy, xrb->pixmap, 0, 0, rb->Width, rb->Height, ~0L, + ZPixmap); freeImg = GL_TRUE; } else if (xrb->ximage) { @@ -2468,7 +2468,7 @@ XMesaBindTexImage(Display *dpy, XMesaBuffer drawable, int buffer, PUBLIC void -XMesaReleaseTexImage(Display *dpy, XMesaBuffer drawable, int buffer) +XMesaReleaseTexImage(XMesaDisplay *dpy, XMesaBuffer drawable, int buffer) { const GLint b = xbuffer_to_renderbuffer(buffer); if (b < 0) diff --git a/src/mesa/drivers/x11/xm_image.h b/src/mesa/drivers/x11/xm_image.h index 240ccee1af..2a5e0f3777 100644 --- a/src/mesa/drivers/x11/xm_image.h +++ b/src/mesa/drivers/x11/xm_image.h @@ -36,13 +36,6 @@ SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. #define XMESA_USE_PUTPIXEL_MACRO -struct _XMesaImageRec { - int width, height; - char *data; - int bytes_per_line; /* Padded to 32 bits */ - int bits_per_pixel; -}; - extern XMesaImage *XMesaCreateImage(int bitsPerPixel, int width, int height, char *data); extern void XMesaDestroyImage(XMesaImage *image); -- cgit v1.2.3 From 043d219b6da0636886f739613380cf44e334f268 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Tue, 22 May 2007 14:08:10 +0200 Subject: Add interfaces for overriding texture images with driver specific 'offsets'. To be used by AIGLX for GLX_EXT_texture_from_pixmap without several additional data copies. --- include/GL/internal/dri_interface.h | 12 ++++++++++++ src/mesa/drivers/dri/common/dri_util.c | 3 +++ src/mesa/drivers/dri/common/dri_util.h | 6 ++++++ 3 files changed, 21 insertions(+) (limited to 'include') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index a3de2c6aab..8d24e311f8 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -361,6 +361,18 @@ struct __DRIscreenRec { void * (*createNewContext)(__DRInativeDisplay *dpy, const __GLcontextModes *modes, int render_type, void *sharedPrivate, __DRIcontext *pctx); + + /** + * Method to override base texture image with a driver specific 'offset'. + * The depth passed in allows e.g. to ignore the alpha channel of texture + * images where the non-alpha components don't occupy a whole texel. + * + * For GLX_EXT_texture_from_pixmap with AIGLX. + * + * \since Internal API version 20070121. + */ + void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname, + unsigned long long offset, GLint depth, GLuint pitch); }; /** diff --git a/src/mesa/drivers/dri/common/dri_util.c b/src/mesa/drivers/dri/common/dri_util.c index 07ac4c7cd5..dd52f7e915 100644 --- a/src/mesa/drivers/dri/common/dri_util.c +++ b/src/mesa/drivers/dri/common/dri_util.c @@ -995,6 +995,9 @@ __driUtilCreateNewScreen(__DRInativeDisplay *dpy, int scrn, __DRIscreen *psc, psc->getMSC = driGetMSC; psc->createNewContext = driCreateNewContext; + if (internal_api_version >= 20070121) + psc->setTexOffset = psp->DriverAPI.setTexOffset; + if ( (psp->DriverAPI.InitDriver != NULL) && !(*psp->DriverAPI.InitDriver)(psp) ) { _mesa_free( psp ); diff --git a/src/mesa/drivers/dri/common/dri_util.h b/src/mesa/drivers/dri/common/dri_util.h index 8639535abb..539d28d114 100644 --- a/src/mesa/drivers/dri/common/dri_util.h +++ b/src/mesa/drivers/dri/common/dri_util.h @@ -189,6 +189,12 @@ struct __DriverAPIRec { /*@}*/ void (*CopySubBuffer)(__DRIdrawablePrivate *driDrawPriv, int x, int y, int w, int h); + + /** + * See corresponding field in \c __DRIscreenRec. + */ + void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname, + unsigned long long offset, GLint depth, GLuint pitch); }; -- cgit v1.2.3