From 0b932284f2294a1dc02004d3b6ef6dfb633bc4bb Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:09 +0200 Subject: dri_inteface: add define for checking presence of drm.h __NOT_HAVE_DRM_H is a like a feature, defined by default on specific platforms and allows to be defined externally as well. __NOT_HAVE_DRM_H should only be used by xserver and mesa swrast_dri drivers --- src/mesa/drivers/dri/swrast/Makefile | 2 ++ 1 file changed, 2 insertions(+) (limited to 'src/mesa/drivers/dri/swrast') diff --git a/src/mesa/drivers/dri/swrast/Makefile b/src/mesa/drivers/dri/swrast/Makefile index cc59eefdb2d..aeefece4402 100644 --- a/src/mesa/drivers/dri/swrast/Makefile +++ b/src/mesa/drivers/dri/swrast/Makefile @@ -5,6 +5,8 @@ include $(TOP)/configs/current LIBNAME = swrast_dri.so +DRIVER_DEFINES = -D__NOT_HAVE_DRM_H + DRIVER_SOURCES = \ swrast.c \ swrast_span.c -- cgit v1.2.3 From a13bcf945fdc455c184284552d8f39c57982d61f Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Fri, 19 Mar 2010 02:38:10 +0200 Subject: rename dri_sw to drisw_util for consistency --- src/mesa/drivers/dri/common/dri_sw.c | 267 ------------------------------ src/mesa/drivers/dri/common/dri_sw.h | 112 ------------- src/mesa/drivers/dri/common/drisw_util.c | 267 ++++++++++++++++++++++++++++++ src/mesa/drivers/dri/common/drisw_util.h | 112 +++++++++++++ src/mesa/drivers/dri/swrast/Makefile | 2 +- src/mesa/drivers/dri/swrast/swrast_priv.h | 2 +- 6 files changed, 381 insertions(+), 381 deletions(-) delete mode 100644 src/mesa/drivers/dri/common/dri_sw.c delete mode 100644 src/mesa/drivers/dri/common/dri_sw.h create mode 100644 src/mesa/drivers/dri/common/drisw_util.c create mode 100644 src/mesa/drivers/dri/common/drisw_util.h (limited to 'src/mesa/drivers/dri/swrast') diff --git a/src/mesa/drivers/dri/common/dri_sw.c b/src/mesa/drivers/dri/common/dri_sw.c deleted file mode 100644 index b7f9036f473..00000000000 --- a/src/mesa/drivers/dri/common/dri_sw.c +++ /dev/null @@ -1,267 +0,0 @@ -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * Copyright 2010 George Sapountzis - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - -/** - * \file dri_sw.c - * - * DRISW utility functions, i.e. dri_util.c stripped from drm-specific bits. - */ - -#include "dri_sw.h" -#include "utils.h" - - -/** - * Screen functions - */ - -static void -setupLoaderExtensions(__DRIscreen *psp, - const __DRIextension **extensions) -{ - int i; - - for (i = 0; extensions[i]; i++) { - if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0) - psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i]; - } -} - -static __DRIscreen * -driCreateNewScreen(int scrn, const __DRIextension **extensions, - const __DRIconfig ***driver_configs, void *data) -{ - static const __DRIextension *emptyExtensionList[] = { NULL }; - __DRIscreen *psp; - - (void) data; - - psp = CALLOC_STRUCT(__DRIscreenRec); - if (!psp) - return NULL; - - setupLoaderExtensions(psp, extensions); - - psp->extensions = emptyExtensionList; - psp->myNum = scrn; - - *driver_configs = driDriverAPI.InitScreen(psp); - - if (*driver_configs == NULL) { - FREE(psp); - return NULL; - } - - return psp; -} - -static void driDestroyScreen(__DRIscreen *psp) -{ - if (psp) { - driDriverAPI.DestroyScreen(psp); - - FREE(psp); - } -} - -static const __DRIextension **driGetExtensions(__DRIscreen *psp) -{ - return psp->extensions; -} - - -/** - * Context functions - */ - -static __DRIcontext * -driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, - __DRIcontext *shared, void *data) -{ - __DRIcontext *pcp; - void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; - - pcp = CALLOC_STRUCT(__DRIcontextRec); - if (!pcp) - return NULL; - - pcp->loaderPrivate = data; - - pcp->driScreenPriv = psp; - pcp->driDrawablePriv = NULL; - pcp->driReadablePriv = NULL; - - if (!driDriverAPI.CreateContext(&config->modes, pcp, shareCtx)) { - FREE(pcp); - return NULL; - } - - return pcp; -} - -static void -driDestroyContext(__DRIcontext *pcp) -{ - if (pcp) { - driDriverAPI.DestroyContext(pcp); - FREE(pcp); - } -} - -static int -driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask) -{ - return GL_FALSE; -} - -static void dri_get_drawable(__DRIdrawable *pdp); -static void dri_put_drawable(__DRIdrawable *pdp); - -static int driBindContext(__DRIcontext *pcp, - __DRIdrawable *pdp, - __DRIdrawable *prp) -{ - /* Bind the drawable to the context */ - if (pcp) { - pcp->driDrawablePriv = pdp; - pcp->driReadablePriv = prp; - if (pdp) { - dri_get_drawable(pdp); - } - if ( prp && pdp != prp ) { - dri_get_drawable(prp); - } - } - - return driDriverAPI.MakeCurrent(pcp, pdp, prp); -} - -static int driUnbindContext(__DRIcontext *pcp) -{ - __DRIdrawable *pdp; - __DRIdrawable *prp; - - if (pcp == NULL) - return GL_FALSE; - - pdp = pcp->driDrawablePriv; - prp = pcp->driReadablePriv; - - /* already unbound */ - if (!pdp && !prp) - return GL_TRUE; - - driDriverAPI.UnbindContext(pcp); - - dri_put_drawable(pdp); - - if (prp != pdp) { - dri_put_drawable(prp); - } - - pcp->driDrawablePriv = NULL; - pcp->driReadablePriv = NULL; - - return GL_TRUE; -} - - -/** - * Drawable functions - */ - -static void dri_get_drawable(__DRIdrawable *pdp) -{ - pdp->refcount++; -} - -static void dri_put_drawable(__DRIdrawable *pdp) -{ - if (pdp) { - pdp->refcount--; - if (pdp->refcount) - return; - - driDriverAPI.DestroyBuffer(pdp); - - FREE(pdp); - } -} - -static __DRIdrawable * -driCreateNewDrawable(__DRIscreen *psp, - const __DRIconfig *config, void *data) -{ - __DRIdrawable *pdp; - - pdp = CALLOC_STRUCT(__DRIdrawableRec); - if (!pdp) - return NULL; - - pdp->loaderPrivate = data; - - pdp->driScreenPriv = psp; - - dri_get_drawable(pdp); - - if (!driDriverAPI.CreateBuffer(psp, pdp, &config->modes, GL_FALSE)) { - FREE(pdp); - return NULL; - } - - return pdp; -} - -static void -driDestroyDrawable(__DRIdrawable *pdp) -{ - dri_put_drawable(pdp); -} - -static void driSwapBuffers(__DRIdrawable *pdp) -{ - driDriverAPI.SwapBuffers(pdp); -} - -const __DRIcoreExtension driCoreExtension = { - { __DRI_CORE, __DRI_CORE_VERSION }, - NULL, /* driCreateNewScreen */ - driDestroyScreen, - driGetExtensions, - driGetConfigAttrib, - driIndexConfigAttrib, - NULL, /* driCreateNewDrawable */ - driDestroyDrawable, - driSwapBuffers, - driCreateNewContext, - driCopyContext, - driDestroyContext, - driBindContext, - driUnbindContext -}; - -const __DRIswrastExtension driSWRastExtension = { - { __DRI_SWRAST, __DRI_SWRAST_VERSION }, - driCreateNewScreen, - driCreateNewDrawable -}; diff --git a/src/mesa/drivers/dri/common/dri_sw.h b/src/mesa/drivers/dri/common/dri_sw.h deleted file mode 100644 index e353e26b34d..00000000000 --- a/src/mesa/drivers/dri/common/dri_sw.h +++ /dev/null @@ -1,112 +0,0 @@ -/* - * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. - * All Rights Reserved. - * Copyright 2010 George Sapountzis - * - * Permission is hereby granted, free of charge, to any person obtaining a - * copy of this software and associated documentation files (the "Software"), - * to deal in the Software without restriction, including without limitation - * the rights to use, copy, modify, merge, publish, distribute, sublicense, - * and/or sell copies of the Software, and to permit persons to whom the - * Software is furnished to do so, subject to the following conditions: - * - * The above copyright notice and this permission notice shall be included - * in all copies or substantial portions of the Software. - * - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS - * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, - * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL - * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN - * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. - */ - - -#ifndef _DRI_SW_H -#define _DRI_SW_H - -#include -#include -#include - - -/** - * Extensions - */ -extern const __DRIcoreExtension driCoreExtension; -extern const __DRIswrastExtension driSWRastExtension; - - -/** - * Data types - */ -struct __DRIscreenRec { - int myNum; - - int fd; - - void *private; - - const __DRIextension **extensions; - - const __DRIswrastLoaderExtension *swrast_loader; -}; - -struct __DRIcontextRec { - - void *driverPrivate; - - void *loaderPrivate; - - __DRIdrawable *driDrawablePriv; - - __DRIdrawable *driReadablePriv; - - __DRIscreen *driScreenPriv; -}; - -struct __DRIdrawableRec { - - void *driverPrivate; - - void *loaderPrivate; - - __DRIscreen *driScreenPriv; - - int refcount; -}; - - -/** - * Driver callback functions - */ -struct __DriverAPIRec { - const __DRIconfig **(*InitScreen) (__DRIscreen * priv); - - void (*DestroyScreen)(__DRIscreen *driScrnPriv); - - GLboolean (*CreateContext)(const __GLcontextModes *glVis, - __DRIcontext *driContextPriv, - void *sharedContextPrivate); - - void (*DestroyContext)(__DRIcontext *driContextPriv); - - GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv, - __DRIdrawable *driDrawPriv, - const __GLcontextModes *glVis, - GLboolean pixmapBuffer); - - void (*DestroyBuffer)(__DRIdrawable *driDrawPriv); - - void (*SwapBuffers)(__DRIdrawable *driDrawPriv); - - GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv, - __DRIdrawable *driDrawPriv, - __DRIdrawable *driReadPriv); - - GLboolean (*UnbindContext)(__DRIcontext *driContextPriv); -}; - -extern const struct __DriverAPIRec driDriverAPI; - -#endif /* _DRI_SW_H */ diff --git a/src/mesa/drivers/dri/common/drisw_util.c b/src/mesa/drivers/dri/common/drisw_util.c new file mode 100644 index 00000000000..141ca302d08 --- /dev/null +++ b/src/mesa/drivers/dri/common/drisw_util.c @@ -0,0 +1,267 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + +/** + * \file drisw_util.c + * + * DRISW utility functions, i.e. dri_util.c stripped from drm-specific bits. + */ + +#include "drisw_util.h" +#include "utils.h" + + +/** + * Screen functions + */ + +static void +setupLoaderExtensions(__DRIscreen *psp, + const __DRIextension **extensions) +{ + int i; + + for (i = 0; extensions[i]; i++) { + if (strcmp(extensions[i]->name, __DRI_SWRAST_LOADER) == 0) + psp->swrast_loader = (__DRIswrastLoaderExtension *) extensions[i]; + } +} + +static __DRIscreen * +driCreateNewScreen(int scrn, const __DRIextension **extensions, + const __DRIconfig ***driver_configs, void *data) +{ + static const __DRIextension *emptyExtensionList[] = { NULL }; + __DRIscreen *psp; + + (void) data; + + psp = CALLOC_STRUCT(__DRIscreenRec); + if (!psp) + return NULL; + + setupLoaderExtensions(psp, extensions); + + psp->extensions = emptyExtensionList; + psp->myNum = scrn; + + *driver_configs = driDriverAPI.InitScreen(psp); + + if (*driver_configs == NULL) { + FREE(psp); + return NULL; + } + + return psp; +} + +static void driDestroyScreen(__DRIscreen *psp) +{ + if (psp) { + driDriverAPI.DestroyScreen(psp); + + FREE(psp); + } +} + +static const __DRIextension **driGetExtensions(__DRIscreen *psp) +{ + return psp->extensions; +} + + +/** + * Context functions + */ + +static __DRIcontext * +driCreateNewContext(__DRIscreen *psp, const __DRIconfig *config, + __DRIcontext *shared, void *data) +{ + __DRIcontext *pcp; + void * const shareCtx = (shared != NULL) ? shared->driverPrivate : NULL; + + pcp = CALLOC_STRUCT(__DRIcontextRec); + if (!pcp) + return NULL; + + pcp->loaderPrivate = data; + + pcp->driScreenPriv = psp; + pcp->driDrawablePriv = NULL; + pcp->driReadablePriv = NULL; + + if (!driDriverAPI.CreateContext(&config->modes, pcp, shareCtx)) { + FREE(pcp); + return NULL; + } + + return pcp; +} + +static void +driDestroyContext(__DRIcontext *pcp) +{ + if (pcp) { + driDriverAPI.DestroyContext(pcp); + FREE(pcp); + } +} + +static int +driCopyContext(__DRIcontext *dst, __DRIcontext *src, unsigned long mask) +{ + return GL_FALSE; +} + +static void dri_get_drawable(__DRIdrawable *pdp); +static void dri_put_drawable(__DRIdrawable *pdp); + +static int driBindContext(__DRIcontext *pcp, + __DRIdrawable *pdp, + __DRIdrawable *prp) +{ + /* Bind the drawable to the context */ + if (pcp) { + pcp->driDrawablePriv = pdp; + pcp->driReadablePriv = prp; + if (pdp) { + dri_get_drawable(pdp); + } + if ( prp && pdp != prp ) { + dri_get_drawable(prp); + } + } + + return driDriverAPI.MakeCurrent(pcp, pdp, prp); +} + +static int driUnbindContext(__DRIcontext *pcp) +{ + __DRIdrawable *pdp; + __DRIdrawable *prp; + + if (pcp == NULL) + return GL_FALSE; + + pdp = pcp->driDrawablePriv; + prp = pcp->driReadablePriv; + + /* already unbound */ + if (!pdp && !prp) + return GL_TRUE; + + driDriverAPI.UnbindContext(pcp); + + dri_put_drawable(pdp); + + if (prp != pdp) { + dri_put_drawable(prp); + } + + pcp->driDrawablePriv = NULL; + pcp->driReadablePriv = NULL; + + return GL_TRUE; +} + + +/** + * Drawable functions + */ + +static void dri_get_drawable(__DRIdrawable *pdp) +{ + pdp->refcount++; +} + +static void dri_put_drawable(__DRIdrawable *pdp) +{ + if (pdp) { + pdp->refcount--; + if (pdp->refcount) + return; + + driDriverAPI.DestroyBuffer(pdp); + + FREE(pdp); + } +} + +static __DRIdrawable * +driCreateNewDrawable(__DRIscreen *psp, + const __DRIconfig *config, void *data) +{ + __DRIdrawable *pdp; + + pdp = CALLOC_STRUCT(__DRIdrawableRec); + if (!pdp) + return NULL; + + pdp->loaderPrivate = data; + + pdp->driScreenPriv = psp; + + dri_get_drawable(pdp); + + if (!driDriverAPI.CreateBuffer(psp, pdp, &config->modes, GL_FALSE)) { + FREE(pdp); + return NULL; + } + + return pdp; +} + +static void +driDestroyDrawable(__DRIdrawable *pdp) +{ + dri_put_drawable(pdp); +} + +static void driSwapBuffers(__DRIdrawable *pdp) +{ + driDriverAPI.SwapBuffers(pdp); +} + +const __DRIcoreExtension driCoreExtension = { + { __DRI_CORE, __DRI_CORE_VERSION }, + NULL, /* driCreateNewScreen */ + driDestroyScreen, + driGetExtensions, + driGetConfigAttrib, + driIndexConfigAttrib, + NULL, /* driCreateNewDrawable */ + driDestroyDrawable, + driSwapBuffers, + driCreateNewContext, + driCopyContext, + driDestroyContext, + driBindContext, + driUnbindContext +}; + +const __DRIswrastExtension driSWRastExtension = { + { __DRI_SWRAST, __DRI_SWRAST_VERSION }, + driCreateNewScreen, + driCreateNewDrawable +}; diff --git a/src/mesa/drivers/dri/common/drisw_util.h b/src/mesa/drivers/dri/common/drisw_util.h new file mode 100644 index 00000000000..e353e26b34d --- /dev/null +++ b/src/mesa/drivers/dri/common/drisw_util.h @@ -0,0 +1,112 @@ +/* + * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas. + * All Rights Reserved. + * Copyright 2010 George Sapountzis + * + * Permission is hereby granted, free of charge, to any person obtaining a + * copy of this software and associated documentation files (the "Software"), + * to deal in the Software without restriction, including without limitation + * the rights to use, copy, modify, merge, publish, distribute, sublicense, + * and/or sell copies of the Software, and to permit persons to whom the + * Software is furnished to do so, subject to the following conditions: + * + * The above copyright notice and this permission notice shall be included + * in all copies or substantial portions of the Software. + * + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS + * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, + * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL + * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN + * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. + */ + + +#ifndef _DRI_SW_H +#define _DRI_SW_H + +#include +#include +#include + + +/** + * Extensions + */ +extern const __DRIcoreExtension driCoreExtension; +extern const __DRIswrastExtension driSWRastExtension; + + +/** + * Data types + */ +struct __DRIscreenRec { + int myNum; + + int fd; + + void *private; + + const __DRIextension **extensions; + + const __DRIswrastLoaderExtension *swrast_loader; +}; + +struct __DRIcontextRec { + + void *driverPrivate; + + void *loaderPrivate; + + __DRIdrawable *driDrawablePriv; + + __DRIdrawable *driReadablePriv; + + __DRIscreen *driScreenPriv; +}; + +struct __DRIdrawableRec { + + void *driverPrivate; + + void *loaderPrivate; + + __DRIscreen *driScreenPriv; + + int refcount; +}; + + +/** + * Driver callback functions + */ +struct __DriverAPIRec { + const __DRIconfig **(*InitScreen) (__DRIscreen * priv); + + void (*DestroyScreen)(__DRIscreen *driScrnPriv); + + GLboolean (*CreateContext)(const __GLcontextModes *glVis, + __DRIcontext *driContextPriv, + void *sharedContextPrivate); + + void (*DestroyContext)(__DRIcontext *driContextPriv); + + GLboolean (*CreateBuffer)(__DRIscreen *driScrnPriv, + __DRIdrawable *driDrawPriv, + const __GLcontextModes *glVis, + GLboolean pixmapBuffer); + + void (*DestroyBuffer)(__DRIdrawable *driDrawPriv); + + void (*SwapBuffers)(__DRIdrawable *driDrawPriv); + + GLboolean (*MakeCurrent)(__DRIcontext *driContextPriv, + __DRIdrawable *driDrawPriv, + __DRIdrawable *driReadPriv); + + GLboolean (*UnbindContext)(__DRIcontext *driContextPriv); +}; + +extern const struct __DriverAPIRec driDriverAPI; + +#endif /* _DRI_SW_H */ diff --git a/src/mesa/drivers/dri/swrast/Makefile b/src/mesa/drivers/dri/swrast/Makefile index aeefece4402..d2cf6dbc55b 100644 --- a/src/mesa/drivers/dri/swrast/Makefile +++ b/src/mesa/drivers/dri/swrast/Makefile @@ -20,7 +20,7 @@ ASM_SOURCES = SWRAST_COMMON_SOURCES = \ ../../common/driverfuncs.c \ ../common/utils.c \ - ../common/dri_sw.c + ../common/drisw_util.c include ../Makefile.template diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index 77670d89a5e..007642be95f 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -30,7 +30,7 @@ #include #include #include "main/mtypes.h" -#include "dri_sw.h" +#include "drisw_util.h" /** -- cgit v1.2.3 From b005e751778736d0d743f734207582a03ce70e77 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 26 Mar 2010 16:29:59 +0100 Subject: dri/swrast: Fix missed conversion of one pixel pointer increment. This probably broke the swrast DRI driver when running X in depth 16. (cherry picked from commit 6ec259eb17dfbb74972b8cffb4e02a9dbab288cc) --- src/mesa/drivers/dri/swrast/swrast_span.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/mesa/drivers/dri/swrast') diff --git a/src/mesa/drivers/dri/swrast/swrast_span.c b/src/mesa/drivers/dri/swrast/swrast_span.c index 5290dc82b91..d896e154f76 100644 --- a/src/mesa/drivers/dri/swrast/swrast_span.c +++ b/src/mesa/drivers/dri/swrast/swrast_span.c @@ -240,7 +240,7 @@ static const GLubyte kernel[16] = { struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); #define INIT_PIXEL_PTR(P, X, Y) \ GLushort *P = (GLushort *)row; -#define INC_PIXEL_PTR(P) P += 2 +#define INC_PIXEL_PTR(P) P++ #define STORE_PIXEL(DST, X, Y, VALUE) \ STORE_PIXEL_R5G6B5(DST, X, Y, VALUE) #define FETCH_PIXEL(DST, SRC) \ -- cgit v1.2.3 From 7996f0fc2c167c84552701be7a48d20a897e7978 Mon Sep 17 00:00:00 2001 From: Michel Dänzer Date: Fri, 26 Mar 2010 16:29:59 +0100 Subject: dri/swrast: Fix frontbuffer rendering. Was broken since the endianness fixes. (cherry picked from commit 4cf14fa80bda5f4ea65bef3a64e748e064d0bde1) --- src/mesa/drivers/dri/swrast/swrast_spantemp.h | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) (limited to 'src/mesa/drivers/dri/swrast') diff --git a/src/mesa/drivers/dri/swrast/swrast_spantemp.h b/src/mesa/drivers/dri/swrast/swrast_spantemp.h index 879a0c12e76..84873617147 100644 --- a/src/mesa/drivers/dri/swrast/swrast_spantemp.h +++ b/src/mesa/drivers/dri/swrast/swrast_spantemp.h @@ -37,7 +37,7 @@ #define _SWRAST_SPANTEMP_ONCE static INLINE void -PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLubyte *p ) +PUT_PIXEL( GLcontext *glCtx, GLint x, GLint y, GLvoid *p ) { __DRIcontext *ctx = swrast_context(glCtx); __DRIdrawable *draw = swrast_drawable(glCtx->DrawBuffer); @@ -168,7 +168,8 @@ NAME(put_row)( GLcontext *ctx, struct gl_renderbuffer *rb, if (mask) { for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); STORE_PIXEL(pixel, x + i, y, src[i]); PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel); } @@ -200,7 +201,8 @@ NAME(put_row_rgb)( GLcontext *ctx, struct gl_renderbuffer *rb, if (mask) { for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); #ifdef STORE_PIXEL_RGB STORE_PIXEL_RGB(pixel, x + i, y, src[i]); #else @@ -240,7 +242,8 @@ NAME(put_mono_row)( GLcontext *ctx, struct gl_renderbuffer *rb, if (mask) { for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); STORE_PIXEL(pixel, x + i, y, src); PUT_PIXEL(ctx, x + i, YFLIP(xrb, y), pixel); } @@ -272,7 +275,8 @@ NAME(put_values)( GLcontext *ctx, struct gl_renderbuffer *rb, ASSERT(mask); for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); STORE_PIXEL(pixel, x[i], y[i], src[i]); PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel); } @@ -294,7 +298,8 @@ NAME(put_mono_values)( GLcontext *ctx, struct gl_renderbuffer *rb, ASSERT(mask); for (i = 0; i < count; i++) { if (mask[i]) { - RB_TYPE pixel[4]; + RB_TYPE row[4]; + INIT_PIXEL_PTR(pixel, x, y); STORE_PIXEL(pixel, x[i], y[i], src); PUT_PIXEL(ctx, x[i], YFLIP(xrb, y[i]), pixel); } -- cgit v1.2.3 From f4e561ce127cf484d7c76c29b8cd026c9ad5cebc Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 27 Mar 2010 20:32:52 +0200 Subject: drisw: make stride issue profound --- include/GL/internal/dri_interface.h | 12 ++-- src/gallium/state_trackers/dri/sw/drisw.c | 10 ++-- src/gallium/winsys/sw/dri/dri_sw_winsys.c | 6 +- src/glx/drisw_glx.c | 92 ++++++++++++++++++++----------- src/mesa/drivers/dri/swrast/swrast.c | 18 ++++-- src/mesa/drivers/dri/swrast/swrast_priv.h | 8 --- 6 files changed, 88 insertions(+), 58 deletions(-) (limited to 'src/mesa/drivers/dri/swrast') diff --git a/include/GL/internal/dri_interface.h b/include/GL/internal/dri_interface.h index aa56eb45d79..fa9b7c4bf21 100644 --- a/include/GL/internal/dri_interface.h +++ b/include/GL/internal/dri_interface.h @@ -416,15 +416,15 @@ struct __DRIswrastLoaderExtensionRec { * Put image to drawable */ void (*putImage)(__DRIdrawable *drawable, int op, - int x, int y, int width, int height, char *data, - void *loaderPrivate); + int x, int y, int width, int height, + char *data, void *loaderPrivate); /** - * Get image from drawable + * Get image from readable */ - void (*getImage)(__DRIdrawable *drawable, - int x, int y, int width, int height, char *data, - void *loaderPrivate); + void (*getImage)(__DRIdrawable *readable, + int x, int y, int width, int height, + char *data, void *loaderPrivate); }; /** diff --git a/src/gallium/state_trackers/dri/sw/drisw.c b/src/gallium/state_trackers/dri/sw/drisw.c index 745941d5501..a75fdf17899 100644 --- a/src/gallium/state_trackers/dri/sw/drisw.c +++ b/src/gallium/state_trackers/dri/sw/drisw.c @@ -38,16 +38,16 @@ * * drisw_api: * - * Define drisw_api similarly to dri_api and use it to call the loader. This is - * predicated on support for calling the loader from the winsys, which has to - * grow for DRI2 as well. + * Define drisw_api similarly to dri1_api and use it to call the loader. This + * is predicated on support for calling the loader from the winsys, which has + * to grow for DRI2 as well. * - * xshm: + * xshm / texture_from_pixmap / EGLImage: * * Allow the loaders to use the XSHM extension. It probably requires callbacks * for createImage/destroyImage similar to DRI2 getBuffers. Probably not worth * it, given the scope of DRISW, unless it falls naturally from properly - * solving the above two issues. + * solving the other issues. */ #include "util/u_memory.h" diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c index 5549e152ee8..9e8c31282d4 100644 --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -63,11 +63,11 @@ xm_is_displaytarget_format_supported( struct sw_winsys *ws, } static INLINE int -bytes_per_line(unsigned stride, unsigned mul) +bytes_per_line(unsigned pitch_bits, unsigned mul) { unsigned mask = mul - 1; - return ((stride * 8 + mask) & ~mask) / 8; + return ((pitch_bits + mask) & ~mask) / 8; } /* pipe_screen::texture_create DISPLAY_TARGET / SCANOUT / SHARED */ @@ -88,7 +88,7 @@ xm_displaytarget_create(struct sw_winsys *winsys, format_stride = util_format_get_stride(format, width); xm_stride = align(format_stride, alignment); - loader_stride = bytes_per_line(format_stride, 32); + loader_stride = bytes_per_line(format_stride * 8, 32); nblocksy = util_format_get_nblocksy(format, height); size = xm_stride * nblocksy; diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index 99f8f2cbf06..ca85ae3a313 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -53,7 +53,6 @@ struct __GLXDRIdrawablePrivateRec XVisualInfo *visinfo; XImage *ximage; - int bpp; }; /** @@ -90,13 +89,10 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp, pdp->visinfo->depth, ZPixmap, 0, /* format, offset */ NULL, /* data */ - 0, 0, /* size */ - 32, /* bitmap_pad */ + 0, 0, /* width, height */ + 8, /* bitmap_pad */ 0); /* bytes_per_line */ - /* get the true number of bits per pixel */ - pdp->bpp = pdp->ximage->bits_per_pixel; - return True; } @@ -112,7 +108,8 @@ XDestroyDrawable(__GLXDRIdrawablePrivate * pdp, Display * dpy, XID drawable) static void swrastGetDrawableInfo(__DRIdrawable * draw, - int *x, int *y, int *w, int *h, void *loaderPrivate) + int *x, int *y, int *w, int *h, + void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); @@ -121,26 +118,20 @@ swrastGetDrawableInfo(__DRIdrawable * draw, Window root; Status stat; - unsigned int bw, depth; + unsigned uw, uh, bw, depth; drawable = pdraw->xDrawable; stat = XGetGeometry(dpy, drawable, &root, - x, y, (unsigned int *) w, (unsigned int *) h, - &bw, &depth); -} - -static inline int -bytes_per_line(int w, int bpp, unsigned mul) -{ - unsigned mask = mul - 1; - - return ((w * bpp + mask) & ~mask) / 8; + x, y, &uw, &uh, &bw, &depth); + *w = uw; + *h = uh; } static void -swrastPutImage(__DRIdrawable * draw, int op, - int x, int y, int w, int h, char *data, void *loaderPrivate) +swrastPutImage2(__DRIdrawable * draw, int op, + int x, int y, int w, int h, + char *data, int pitch, void *loaderPrivate) { __GLXDRIdrawablePrivate *pdp = loaderPrivate; __GLXDRIdrawable *pdraw = &(pdp->base); @@ -166,7 +157,7 @@ swrastPutImage(__DRIdrawable * draw, int op, ximage->data = data; ximage->width = w; ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); + ximage->bytes_per_line = pitch; XPutImage(dpy, drawable, gc, ximage, 0, 0, x, y, w, h); @@ -174,28 +165,67 @@ swrastPutImage(__DRIdrawable * draw, int op, } static void -swrastGetImage(__DRIdrawable * draw, - int x, int y, int w, int h, char *data, void *loaderPrivate) +swrastGetImage2(__DRIdrawable * read, + int x, int y, int w, int h, + char *data, int pitch, void *loaderPrivate) { - __GLXDRIdrawablePrivate *pdp = loaderPrivate; - __GLXDRIdrawable *pdraw = &(pdp->base); - Display *dpy = pdraw->psc->dpy; - Drawable drawable; + __GLXDRIdrawablePrivate *prp = loaderPrivate; + __GLXDRIdrawable *pread = &(prp->base); + Display *dpy = pread->psc->dpy; + Drawable readable; XImage *ximage; - drawable = pdraw->xDrawable; + readable = pread->xDrawable; - ximage = pdp->ximage; + ximage = prp->ximage; ximage->data = data; ximage->width = w; ximage->height = h; - ximage->bytes_per_line = bytes_per_line(w, pdp->bpp, 32); + ximage->bytes_per_line = pitch; - XGetSubImage(dpy, drawable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); + XGetSubImage(dpy, readable, x, y, w, h, ~0L, ZPixmap, ximage, 0, 0); ximage->data = NULL; } +static inline int +bytes_per_line(unsigned pitch_bits, unsigned mul) +{ + unsigned mask = mul - 1; + + return ((pitch_bits + mask) & ~mask) / 8; +} + +static void +swrastPutImage(__DRIdrawable * draw, int op, + int x, int y, int w, int h, + char *data, void *loaderPrivate) +{ + __GLXDRIdrawablePrivate *pdp = loaderPrivate; + int bpp, pitch; + + bpp = pdp->ximage->bits_per_pixel; + + pitch = bytes_per_line(w * bpp, 32); + + swrastPutImage2(draw, op, x, y, w, h, data, pitch, loaderPrivate); +} + +static void +swrastGetImage(__DRIdrawable * read, + int x, int y, int w, int h, + char *data, void *loaderPrivate) +{ + __GLXDRIdrawablePrivate *prp = loaderPrivate; + int bpp, pitch; + + bpp = prp->ximage->bits_per_pixel; + + pitch = bytes_per_line(w * bpp, 32); + + swrastGetImage2(read, x, y, w, h, data, pitch, loaderPrivate); +} + static const __DRIswrastLoaderExtension swrastLoaderExtension = { {__DRI_SWRAST_LOADER, __DRI_SWRAST_LOADER_VERSION}, swrastGetDrawableInfo, diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index e9ca99a86f0..e8df26f3d06 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -206,12 +206,19 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb) free(rb); } +static INLINE int +bytes_per_line(unsigned pitch_bits, unsigned mul) +{ + unsigned mask = mul - 1; + + return ((pitch_bits + mask) & ~mask) / 8; +} + static GLboolean swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, GLenum internalFormat, GLuint width, GLuint height) { struct swrast_renderbuffer *xrb = swrast_renderbuffer(rb); - unsigned mask = PITCH_ALIGN_BITS - 1; TRACE; @@ -219,8 +226,7 @@ swrast_alloc_front_storage(GLcontext *ctx, struct gl_renderbuffer *rb, rb->Width = width; rb->Height = height; - /* always pad to PITCH_ALIGN_BITS */ - xrb->pitch = ((width * xrb->bpp + mask) & ~mask) / 8; + xrb->pitch = bytes_per_line(width * xrb->bpp, 32); return GL_TRUE; } @@ -394,8 +400,10 @@ dri_swap_buffers(__DRIdrawable * dPriv) fb = &drawable->Base; - frontrb = swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); - backrb = swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); + frontrb = + swrast_renderbuffer(fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer); + backrb = + swrast_renderbuffer(fb->Attachment[BUFFER_BACK_LEFT].Renderbuffer); /* check for signle-buffered */ if (backrb == NULL) diff --git a/src/mesa/drivers/dri/swrast/swrast_priv.h b/src/mesa/drivers/dri/swrast/swrast_priv.h index 007642be95f..6679061a983 100644 --- a/src/mesa/drivers/dri/swrast/swrast_priv.h +++ b/src/mesa/drivers/dri/swrast/swrast_priv.h @@ -124,14 +124,6 @@ swrast_renderbuffer(struct gl_renderbuffer *rb) #define PF_R3G3B2 3 /**< 8bpp TrueColor: 3-R, 3-G, 2-B bits */ #define PF_X8R8G8B8 4 /**< 32bpp TrueColor: 8-R, 8-G, 8-B bits */ -/** - * Renderbuffer pitch alignment (in bits). - * - * The xorg loader requires padding images to 32 bits. However, this should - * become a screen/drawable parameter XXX - */ -#define PITCH_ALIGN_BITS 32 - /* swrast_span.c */ -- cgit v1.2.3 From 3bfa23317c6b1b52ec637a03a0b623228ffc95ef Mon Sep 17 00:00:00 2001 From: George Sapountzis Date: Sat, 27 Mar 2010 21:35:25 +0200 Subject: drisw: add comment to libGL about stride --- src/gallium/winsys/sw/dri/dri_sw_winsys.c | 1 + src/glx/drisw_glx.c | 10 +++++++++- src/mesa/drivers/dri/swrast/swrast.c | 1 + 3 files changed, 11 insertions(+), 1 deletion(-) (limited to 'src/mesa/drivers/dri/swrast') diff --git a/src/gallium/winsys/sw/dri/dri_sw_winsys.c b/src/gallium/winsys/sw/dri/dri_sw_winsys.c index 9e8c31282d4..ee8ec91bc52 100644 --- a/src/gallium/winsys/sw/dri/dri_sw_winsys.c +++ b/src/gallium/winsys/sw/dri/dri_sw_winsys.c @@ -62,6 +62,7 @@ xm_is_displaytarget_format_supported( struct sw_winsys *ws, return TRUE; } +/* see bytes_per_line in libGL */ static INLINE int bytes_per_line(unsigned pitch_bits, unsigned mul) { diff --git a/src/glx/drisw_glx.c b/src/glx/drisw_glx.c index ca85ae3a313..5a47e4a097f 100644 --- a/src/glx/drisw_glx.c +++ b/src/glx/drisw_glx.c @@ -90,7 +90,7 @@ XCreateDrawable(__GLXDRIdrawablePrivate * pdp, ZPixmap, 0, /* format, offset */ NULL, /* data */ 0, 0, /* width, height */ - 8, /* bitmap_pad */ + 32, /* bitmap_pad */ 0); /* bytes_per_line */ return True; @@ -188,6 +188,14 @@ swrastGetImage2(__DRIdrawable * read, ximage->data = NULL; } +/** + * Renderbuffer pitch alignment (in bits). + * + * This should be chosen by the driver and the loader (libGL, xserver/glx) + * should use the driver provided pitch. I had a comment that the xserver + * requires padding images to 32 bits. Is this a hard requirement or can it use + * the driver pitch without extra copies ? XXX + */ static inline int bytes_per_line(unsigned pitch_bits, unsigned mul) { diff --git a/src/mesa/drivers/dri/swrast/swrast.c b/src/mesa/drivers/dri/swrast/swrast.c index e8df26f3d06..8b68281fab0 100644 --- a/src/mesa/drivers/dri/swrast/swrast.c +++ b/src/mesa/drivers/dri/swrast/swrast.c @@ -206,6 +206,7 @@ swrast_delete_renderbuffer(struct gl_renderbuffer *rb) free(rb); } +/* see bytes_per_line in libGL */ static INLINE int bytes_per_line(unsigned pitch_bits, unsigned mul) { -- cgit v1.2.3