diff options
Diffstat (limited to 'extras/Mesa/src/mesa/drivers/dri')
24 files changed, 408 insertions, 411 deletions
diff --git a/extras/Mesa/src/mesa/drivers/dri/Makefile.template b/extras/Mesa/src/mesa/drivers/dri/Makefile.template index 75c62af0f..517e00632 100644 --- a/extras/Mesa/src/mesa/drivers/dri/Makefile.template +++ b/extras/Mesa/src/mesa/drivers/dri/Makefile.template @@ -95,6 +95,7 @@ tags: # Remove .o and backup files clean: - -rm -f *.o */*.o *~ *.o *~ *.so server/*.o $(SYMLINKS) depend + -rm -f *.o */*.o *~ *.o *~ *.so server/*.o $(SYMLINKS) + -rm -f depend depend.bak include depend diff --git a/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c b/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c index dd83080cc..88caa34e9 100644 --- a/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c +++ b/extras/Mesa/src/mesa/drivers/dri/common/dri_util.c @@ -141,6 +141,26 @@ __driUtilMessage(const char *f, ...) } } +/* + * fd.o bug #1713: Some rare libGL's have __glXFindDRIScreen defined but do not + * export it via glXGetProcAddress. These are not supported anymore, so print + * an error message to that effect. - ajax 2004-10-26 + */ +typedef __DRIscreen *(*PFNGLXFINDDRISCREEN)(__DRInativeDisplay *, int); + +static __DRIscreen *glx_find_dri_screen(__DRInativeDisplay *d, int i) +{ + PFNGLXFINDDRISCREEN findscreen = + (PFNGLXFINDDRISCREEN)glXGetProcAddress("__glXFindDRIScreen"); + + if (!findscreen) + { + __driUtilMessage("glXGetProcAddress(\"__glXFindDRIScreen\") failed!"); + __driUtilMessage("Your libGL is too old, please upgrade."); + return NULL; + } + else return findscreen(d, i); +} /*****************************************************************/ /** \name Visual utility functions */ @@ -212,23 +232,33 @@ static GLboolean __driAddDrawable(void *drawHash, __DRIdrawable *pdraw) static __DRIdrawable *__driFindDrawable(void *drawHash, __DRIid draw) { int retcode; - __DRIdrawable *pdraw; + union + { + __DRIdrawable *pdraw; + void *ptr; + } p; - retcode = drmHashLookup(drawHash, draw, (void **)&pdraw); + retcode = drmHashLookup(drawHash, draw, &p.ptr); if (retcode) return NULL; - return pdraw; + return p.pdraw; } static void __driRemoveDrawable(void *drawHash, __DRIdrawable *pdraw) { int retcode; - __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private; + union + { + __DRIdrawablePrivate *pdp; + void *ptr; + } p; + + p.pdp = (__DRIdrawablePrivate *)pdraw->private; - retcode = drmHashLookup(drawHash, pdp->draw, (void **)&pdraw); + retcode = drmHashLookup(drawHash, p.pdp->draw, &p.ptr); if (!retcode) { /* Found */ - drmHashDelete(drawHash, pdp->draw); + drmHashDelete(drawHash, p.pdp->draw); } } @@ -286,21 +316,25 @@ static GLboolean __driWindowExists(Display *dpy, GLXDrawable draw) static void __driGarbageCollectDrawables(void *drawHash) { __DRIid draw; - __DRIdrawable *pdraw; __DRInativeDisplay *dpy; + union + { + __DRIdrawable *pdraw; + void *ptr; + } p; - if (drmHashFirst(drawHash, &draw, (void **)&pdraw)) { + if (drmHashFirst(drawHash, &draw, &p.ptr)) { do { - __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)pdraw->private; + __DRIdrawablePrivate *pdp = (__DRIdrawablePrivate *)p.pdraw->private; dpy = pdp->driScreenPriv->display; if (! (*window_exists)(dpy, draw)) { /* Destroy the local drawable data in the hash table, if the drawable no longer exists in the Xserver */ - __driRemoveDrawable(drawHash, pdraw); - (*pdraw->destroyDrawable)(dpy, pdraw->private); - _mesa_free(pdraw); + __driRemoveDrawable(drawHash, p.pdraw); + (*p.pdraw->destroyDrawable)(dpy, p.pdraw->private); + _mesa_free(p.pdraw); } - } while (drmHashNext(drawHash, &draw, (void **)&pdraw)); + } while (drmHashNext(drawHash, &draw, &p.ptr)); } } @@ -353,7 +387,7 @@ static GLboolean driUnbindContext3(__DRInativeDisplay *dpy, int scrn, return GL_FALSE; } - pDRIScreen = __glXFindDRIScreen(dpy, scrn); + pDRIScreen = glx_find_dri_screen(dpy, scrn); if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) { /* ERROR!!! */ return GL_FALSE; @@ -529,7 +563,7 @@ static GLboolean driBindContext3(__DRInativeDisplay *dpy, int scrn, return GL_FALSE; } - pDRIScreen = __glXFindDRIScreen(dpy, scrn); + pDRIScreen = glx_find_dri_screen(dpy, scrn); if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) { /* ERROR!!! */ return GL_FALSE; @@ -563,7 +597,7 @@ static GLboolean driBindContext2(Display *dpy, int scrn, return GL_FALSE; } - pDRIScreen = __glXFindDRIScreen(dpy, scrn); + pDRIScreen = glx_find_dri_screen(dpy, scrn); modes = (driCompareGLXAPIVersion( 20040317 ) >= 0) ? gc->driContext.mode : findConfigMode( dpy, scrn, gc->vid, pDRIScreen ); @@ -793,7 +827,7 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy, int renderType, const int *attrs) { - __DRIscreen * const pDRIScreen = __glXFindDRIScreen(dpy, modes->screen); + __DRIscreen * const pDRIScreen = glx_find_dri_screen(dpy, modes->screen); __DRIscreenPrivate *psp; __DRIdrawablePrivate *pdp; @@ -848,7 +882,7 @@ static void *driCreateNewDrawable(__DRInativeDisplay *dpy, _mesa_free(pdp); return NULL; #else - pdp->getInfo = XF86DRIGetDrawableInfo; + pdp->getInfo = (PFNGLXGETDRAWABLEINFOPROC) XF86DRIGetDrawableInfo; #endif /* DRI_NEW_INTERFACE_ONLY */ } @@ -988,7 +1022,7 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes, __DRIscreenPrivate *psp; void * const shareCtx = (pshare != NULL) ? pshare->driverPrivate : NULL; - pDRIScreen = __glXFindDRIScreen(dpy, modes->screen); + pDRIScreen = glx_find_dri_screen(dpy, modes->screen); if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) { /* ERROR!!! */ return NULL; @@ -1033,16 +1067,16 @@ driCreateNewContext(__DRInativeDisplay *dpy, const __GLcontextModes *modes, pctx->bindContext3 = driBindContext3; pctx->unbindContext3 = driUnbindContext3; #else - pctx->bindContext = driBindContext; - pctx->unbindContext = driUnbindContext; + pctx->bindContext = (void *)driBindContext; + pctx->unbindContext = (void *)driUnbindContext; if ( driCompareGLXAPIVersion( 20030606 ) >= 0 ) { - pctx->bindContext2 = driBindContext2; - pctx->unbindContext2 = driUnbindContext2; + pctx->bindContext2 = (void *)driBindContext2; + pctx->unbindContext2 = (void *)driUnbindContext2; } if ( driCompareGLXAPIVersion( 20040415 ) >= 0 ) { - pctx->bindContext3 = driBindContext3; - pctx->unbindContext3 = driUnbindContext3; + pctx->bindContext3 = (void *)driBindContext3; + pctx->unbindContext3 = (void *)driUnbindContext3; } #endif @@ -1088,7 +1122,7 @@ static void *driCreateContext(Display *dpy, XVisualInfo *vis, __DRIscreen *pDRIScreen; const __GLcontextModes *modes; - pDRIScreen = __glXFindDRIScreen(dpy, vis->screen); + pDRIScreen = glx_find_dri_screen(dpy, vis->screen); if ( (pDRIScreen == NULL) || (pDRIScreen->private == NULL) ) { /* ERROR!!! */ return NULL; diff --git a/extras/Mesa/src/mesa/drivers/dri/common/dri_util.h b/extras/Mesa/src/mesa/drivers/dri/common/dri_util.h index cdb657637..f85a2fb68 100644 --- a/extras/Mesa/src/mesa/drivers/dri/common/dri_util.h +++ b/extras/Mesa/src/mesa/drivers/dri/common/dri_util.h @@ -558,8 +558,11 @@ extern float driCalculateSwapUsage( __DRIdrawablePrivate *dPriv, int64_t last_swap_ust, int64_t current_ust ); +/* Test for the GLX header glx.h */ +#ifndef GLX extern void (*glXGetProcAddress(const GLubyte *procname))( void ); +#endif #endif /* GLX_DIRECT_RENDERING */ diff --git a/extras/Mesa/src/mesa/drivers/dri/common/mmio.h b/extras/Mesa/src/mesa/drivers/dri/common/mmio.h new file mode 100644 index 000000000..1418543dc --- /dev/null +++ b/extras/Mesa/src/mesa/drivers/dri/common/mmio.h @@ -0,0 +1,63 @@ +/* + * (C) Copyright IBM Corporation 2004 + * 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"), + * to deal in the Software without restriction, including without limitation + * on the rights to use, copy, modify, merge, publish, distribute, sub + * license, 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 (including the next + * paragraph) 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 NON-INFRINGEMENT. IN NO EVENT SHALL + * IBM AND/OR THEIR SUPPLIERS 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 mmio.h + * Functions for properly handling memory mapped IO on various platforms. + * + * \author Ian Romanick <idr@us.ibm.com> + */ + + +#ifndef MMIO_H +#define MMIO_H + +#include <inttypes.h> + +#if defined( __powerpc__ ) + +static __inline__ uint32_t +read_MMIO_LE32( volatile void * base, unsigned long offset ) +{ + volatile void * p = ((volatile char *) base) + offset; + uint32_t val; + + __asm__ __volatile__( "lwbrx %0, %1, %2 ; eieio" + : "=r" (val) + : "b" (base), "r" (offset), "m" (p) ); + return val; +} + +#else + +static __inline__ uint32_t +read_MMIO_LE32( volatile void * base, unsigned long offset ) +{ + volatile uint32_t * p = (volatile uint32_t *) (((volatile char *) base) + offset); + return LE32_TO_CPU( p[0] ); +} + +#endif + +#endif /* MMIO_H */ diff --git a/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.c b/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.c index 8eb82a889..b635894fe 100644 --- a/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.c +++ b/extras/Mesa/src/mesa/drivers/dri/common/xmlconfig.c @@ -49,6 +49,10 @@ #undef GET_PROGRAM_NAME #if (defined(__GNU_LIBRARY__) || defined(__GLIBC__)) && !defined(__UCLIBC__) +# if !defined(__GLIBC__) || (__GLIBC__ < 2) +/* These aren't declared in any libc5 header */ +extern char *program_invocation_name, *program_invocation_short_name; +# endif # define GET_PROGRAM_NAME() program_invocation_short_name #elif defined(__FreeBSD__) && (__FreeBSD__ >= 2) # include <osreldate.h> @@ -256,7 +260,7 @@ static GLfloat strToF (const XML_Char *string, const XML_Char **tail) { string = numStart; /* scale of the first digit */ - scale = sign * powf (10.0f, (GLfloat)(pointPos-1 + exponent)); + scale = sign * (GLfloat)pow (10.0, (GLdouble)(pointPos-1 + exponent)); /* second pass: parse digits */ do { diff --git a/extras/Mesa/src/mesa/drivers/dri/dri_client/Makefile b/extras/Mesa/src/mesa/drivers/dri/dri_client/Makefile index ae4bf3055..35a7ed4cd 100644 --- a/extras/Mesa/src/mesa/drivers/dri/dri_client/Makefile +++ b/extras/Mesa/src/mesa/drivers/dri/dri_client/Makefile @@ -53,6 +53,6 @@ dri.a: $(OBJECTS) # Remove .o and backup files clean: - -rm -f *.o */*.o *~ *.so *.a + -rm -f *.o */*.o *~ *.so *.a depend depend.bak include depend diff --git a/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.c b/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.c index d9fc02501..1eb887f67 100644 --- a/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.c +++ b/extras/Mesa/src/mesa/drivers/dri/r128/r128_ioctl.c @@ -43,6 +43,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "swrast/swrast.h" #include "vblank.h" +#include "mmio.h" #define R128_TIMEOUT 2048 #define R128_IDLE_RETRY 32 @@ -225,12 +226,11 @@ static void delay( void ) { static int r128WaitForFrameCompletion( r128ContextPtr rmesa ) { unsigned char *R128MMIO = rmesa->r128Screen->mmio.map; - uint32_t frame; int i; int wait = 0; while ( 1 ) { - frame = *(volatile unsigned int *)(R128MMIO + R128_LAST_FRAME_REG); + uint32_t frame = read_MMIO_LE32( R128MMIO, R128_LAST_FRAME_REG ); if ( rmesa->sarea->last_frame - frame <= R128_MAX_OUTSTANDING ) { break; diff --git a/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.c b/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.c index 34d7c7ffe..0f9245345 100644 --- a/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.c +++ b/extras/Mesa/src/mesa/drivers/dri/r128/r128_tris.c @@ -585,10 +585,16 @@ static void r128RenderStart( GLcontext *ctx ) EMIT_ATTR( _TNL_ATTRIB_POS, EMIT_3F_VIEWPORT, 0, 12 ); rmesa->coloroffset = offset; +#if MESA_LITTLE_ENDIAN EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_BGRA, R128_CCE_VC_FRMT_DIFFUSE_ARGB, 4 ); +#else + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ARGB, + R128_CCE_VC_FRMT_DIFFUSE_ARGB, 4 ); +#endif if ( index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG) ) { +#if MESA_LITTLE_ENDIAN if ( index & _TNL_BIT_COLOR1) { rmesa->specoffset = offset; EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, @@ -601,6 +607,20 @@ static void r128RenderStart( GLcontext *ctx ) 1 ); else EMIT_PAD( 1 ); +#else + if (index & _TNL_BIT_FOG) + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, R128_CCE_VC_FRMT_SPEC_FRGB, + 1 ); + else + EMIT_PAD( 1 ); + + if ( index & _TNL_BIT_COLOR1) { + rmesa->specoffset = offset; + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, + R128_CCE_VC_FRMT_SPEC_FRGB, 3 ); + } else + EMIT_PAD( 3 ); +#endif } if ( index & _TNL_BIT_TEX(0) ) { diff --git a/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.c b/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.c index d5ca2f9b3..6c7a9b106 100644 --- a/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.c +++ b/extras/Mesa/src/mesa/drivers/dri/r200/r200_context.c @@ -143,7 +143,6 @@ static const char * const card_extensions[] = "GL_ATI_texture_env_combine3", "GL_ATI_texture_mirror_once", "GL_MESA_pack_invert", - "GL_MESA_ycbcr_texture", "GL_NV_blend_square", "GL_SGIS_generate_mipmap", NULL @@ -401,6 +400,11 @@ GLboolean r200CreateContext( const __GLcontextModes *glVisual, _math_matrix_set_identity( &rmesa->tmpmat ); driInitExtensions( ctx, card_extensions, GL_TRUE ); + if (rmesa->r200Screen->chipset & R200_CHIPSET_REAL_R200) { + /* yuv textures only work with r200 chips for unknown reasons, the + others get the bit ordering right but don't actually do YUV-RGB conversion */ + _mesa_enable_extension( ctx, "GL_MESA_ycbcr_texture" ); + } if (rmesa->r200Screen->drmSupportsCubeMaps) _mesa_enable_extension( ctx, "GL_ARB_texture_cube_map" ); if (rmesa->r200Screen->drmSupportsBlendColor) { diff --git a/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.c b/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.c index e338e5b35..840a145da 100644 --- a/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.c +++ b/extras/Mesa/src/mesa/drivers/dri/r200/r200_screen.c @@ -91,7 +91,8 @@ static const GLuint __driNConfigOptions = 13; #define PCI_CHIP_R200_QG 0x5147 #define PCI_CHIP_R200_QY 0x5159 #define PCI_CHIP_R200_QZ 0x515A -#define PCI_CHIP_R200_LW 0x4C57 +#define PCI_CHIP_R200_LW 0x4C57 +#define PCI_CHIP_R200_LX 0x4C58 #define PCI_CHIP_R200_LY 0x4C59 #define PCI_CHIP_R200_LZ 0x4C5A #define PCI_CHIP_RV200_QW 0x5157 /* Radeon 7500 - not an R200 at all */ @@ -116,8 +117,14 @@ static const GLuint __driNConfigOptions = 13; #define PCI_CHIP_R200_QM 0x514D #define PCI_CHIP_R200_QN 0x514E #define PCI_CHIP_R200_QO 0x514F /* r200 (non-derived) end */ -/* are the R200 Qh (0x5168) and following needed too? They are not in xf86PciInfo.h - but in the pci database. Maybe just secondary ports or something ? */ +/* are the R200 Qh (0x5168) and following needed too? They are not in + xf86PciInfo.h but in the pci database. Maybe just secondary ports or + something ? Ah well, better be safe than sorry */ +#define PCI_CHIP_R200_Qh 0x5168 +#define PCI_CHIP_R200_Qi 0x5169 +#define PCI_CHIP_R200_Qj 0x516A +#define PCI_CHIP_R200_Qk 0x516B +#define PCI_CHIP_R200_Ql 0x516C #endif @@ -241,6 +248,7 @@ r200CreateScreen( __DRIscreenPrivate *sPriv ) case PCI_CHIP_RV200_QW: case PCI_CHIP_RV200_QX: case PCI_CHIP_R200_LW: + case PCI_CHIP_R200_LX: case PCI_CHIP_R200_LY: case PCI_CHIP_R200_LZ: case PCI_CHIP_RS100_4136: @@ -269,6 +277,11 @@ r200CreateScreen( __DRIscreenPrivate *sPriv ) case PCI_CHIP_R200_QM: case PCI_CHIP_R200_QN: case PCI_CHIP_R200_QO: + case PCI_CHIP_R200_Qh: + case PCI_CHIP_R200_Qi: + case PCI_CHIP_R200_Qj: + case PCI_CHIP_R200_Qk: + case PCI_CHIP_R200_Ql: screen->chipset |= R200_CHIPSET_REAL_R200; /* fallthrough */ default: diff --git a/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.c b/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.c index e1ad976ce..aa54e1628 100644 --- a/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.c +++ b/extras/Mesa/src/mesa/drivers/dri/r200/r200_span.c @@ -195,7 +195,7 @@ static GLuint r200_mba_z32( r200ContextPtr rmesa, GLint x, GLint y ) { GLuint pitch = rmesa->r200Screen->frontPitch; - GLuint b = ((y & 0x3FF) >> 4) * ((pitch & 0xFFF) >> 5) + ((x & 0x3FF) >> 5); + GLuint b = ((y & 0x7FF) >> 4) * ((pitch & 0xFFF) >> 5) + ((x & 0x7FF) >> 5); GLuint a = (BIT(x,0) << 2) | (BIT(y,0) << 3) | @@ -214,7 +214,7 @@ static GLuint r200_mba_z32( r200ContextPtr rmesa, static GLuint r200_mba_z16( r200ContextPtr rmesa, GLint x, GLint y ) { GLuint pitch = rmesa->r200Screen->frontPitch; - GLuint b = ((y & 0x3FF) >> 4) * ((pitch & 0xFFF) >> 6) + ((x & 0x3FF) >> 6); + GLuint b = ((y & 0x7FF) >> 4) * ((pitch & 0xFFF) >> 6) + ((x & 0x7FF) >> 6); GLuint a = (BIT(x,0) << 1) | (BIT(y,0) << 2) | diff --git a/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.c b/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.c index 66662bb4d..18e0b8510 100644 --- a/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.c +++ b/extras/Mesa/src/mesa/drivers/dri/r200/r200_swtcl.c @@ -117,12 +117,17 @@ static void r200SetVertexFormat( GLcontext *ctx ) } rmesa->swtcl.coloroffset = offset; +#if MESA_LITTLE_ENDIAN EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_RGBA, (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT) ); +#else + EMIT_ATTR( _TNL_ATTRIB_COLOR0, EMIT_4UB_4F_ABGR, (R200_VTX_PK_RGBA << R200_VTX_COLOR_0_SHIFT) ); +#endif offset += 1; rmesa->swtcl.specoffset = 0; if (index & (_TNL_BIT_COLOR1|_TNL_BIT_FOG)) { +#if MESA_LITTLE_ENDIAN if (index & _TNL_BIT_COLOR1) { rmesa->swtcl.specoffset = offset; EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_RGB, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) ); @@ -137,6 +142,22 @@ static void r200SetVertexFormat( GLcontext *ctx ) else { EMIT_PAD( 1 ); } +#else + if (index & _TNL_BIT_FOG) { + EMIT_ATTR( _TNL_ATTRIB_FOG, EMIT_1UB_1F, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) ); + } + else { + EMIT_PAD( 1 ); + } + + if (index & _TNL_BIT_COLOR1) { + rmesa->swtcl.specoffset = offset; + EMIT_ATTR( _TNL_ATTRIB_COLOR1, EMIT_3UB_3F_BGR, (R200_VTX_PK_RGBA << R200_VTX_COLOR_1_SHIFT) ); + } + else { + EMIT_PAD( 3 ); + } +#endif } if (index & _TNL_BITS_TEX_ANY) { diff --git a/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.c b/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.c index 746cdb477..80035bc6d 100644 --- a/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.c +++ b/extras/Mesa/src/mesa/drivers/dri/r200/r200_tcl.c @@ -177,11 +177,11 @@ while (0) * discrete and there are no intervening state changes. (Somewhat * duplicates changes to DrawArrays code) */ -static void EMIT_PRIM( GLcontext *ctx, - GLenum prim, - GLuint hwprim, - GLuint start, - GLuint count) +static void r200EmitPrim( GLcontext *ctx, + GLenum prim, + GLuint hwprim, + GLuint start, + GLuint count) { r200ContextPtr rmesa = R200_CONTEXT( ctx ); r200TclPrimitive( ctx, prim, hwprim ); @@ -201,7 +201,9 @@ static void EMIT_PRIM( GLcontext *ctx, count - start ); } - +#define EMIT_PRIM(ctx, prim, hwprim, start, count) do { \ + r200EmitPrim( ctx, prim, hwprim, start, count ); \ + (void) rmesa; } while (0) /* Try & join small primitives */ @@ -221,9 +223,12 @@ static void EMIT_PRIM( GLcontext *ctx, #define EMIT_ELT(dest, offset, x) do { \ int off = offset + ( ( (GLuint)dest & 0x2 ) >> 1 ); \ GLushort *des = (GLushort *)( (GLuint)dest & ~0x2 ); \ - (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); } while (0) + (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); \ + (void)rmesa; } while (0) #else -#define EMIT_ELT(dest, offset, x) (dest)[offset] = (GLushort) (x) +#define EMIT_ELT(dest, offset, x) do { \ + (dest)[offset] = (GLushort) (x); \ + (void)rmesa; } while (0) #endif #define EMIT_TWO_ELTS(dest, offset, x, y) *(GLuint *)((dest)+offset) = ((y)<<16)|(x); diff --git a/extras/Mesa/src/mesa/drivers/dri/r200/r200_texmem.c b/extras/Mesa/src/mesa/drivers/dri/r200/r200_texmem.c index b219995c3..bc937ce6c 100644 --- a/extras/Mesa/src/mesa/drivers/dri/r200/r200_texmem.c +++ b/extras/Mesa/src/mesa/drivers/dri/r200/r200_texmem.c @@ -382,6 +382,14 @@ static void uploadSubImage( r200ContextPtr rmesa, r200TexObjPtr t, /* copy (x,y,width,height,data) */ memcpy( &tmp, &t->image[face][hwlevel], sizeof(tmp) ); + /* Adjust the base offset to account for the Y-offset. This is done, + * instead of just letting the Y-offset automatically take care of it, + * because it is possible, for very large textures, for the Y-offset + * to exceede the [-8192,+8191] range. + */ + tex.offset += tmp.y * 1024; + tmp.y = 0; + LOCK_HARDWARE( rmesa ); do { ret = drmCommandWriteRead( rmesa->dri.fd, DRM_RADEON_TEXTURE, diff --git a/extras/Mesa/src/mesa/drivers/dri/r200/r200_texstate.c b/extras/Mesa/src/mesa/drivers/dri/r200/r200_texstate.c index 003c1e3e4..a84292e5b 100644 --- a/extras/Mesa/src/mesa/drivers/dri/r200/r200_texstate.c +++ b/extras/Mesa/src/mesa/drivers/dri/r200/r200_texstate.c @@ -999,7 +999,7 @@ static void disable_tex( GLcontext *ctx, int unit ) R200_TEX_BLEND_0_ENABLE) << unit); rmesa->hw.ctx.cmd[CTX_PP_CNTL] |= R200_TEX_BLEND_0_ENABLE; - R200_STATECHANGE( rmesa, tcl ); + R200_STATECHANGE( rmesa, vtx ); rmesa->hw.vtx.cmd[VTX_TCL_OUTPUT_VTXFMT_1] &= ~(7 << (unit * 3)); if (rmesa->TclFallback & (R200_TCL_FALLBACK_TEXGEN_0<<unit)) { @@ -1335,8 +1335,14 @@ void r200UpdateTextureState( GLcontext *ctx ) * Texture cache LRU hang workaround ------------- * not needed for r200 derivatives? */ - dbg = 0x0; + /* While the cases below attempt to only enable the workaround in the + * specific cases necessary, they were insufficient. See bugzilla #1519, + * #729, #814. Tests with quake3 showed no impact on performance. + */ + dbg = 0x6; + + /* if (((rmesa->hw.ctx.cmd[CTX_PP_CNTL] & (R200_TEX_0_ENABLE )) && ((((rmesa->hw.tex[0].cmd[TEX_PP_TXFILTER] & R200_MIN_FILTER_MASK)) & 0x04) == 0)) || @@ -1361,7 +1367,7 @@ void r200UpdateTextureState( GLcontext *ctx ) 0x04) == 0))) { dbg |= 0x04; - } + }*/ if (dbg != rmesa->hw.tam.cmd[TAM_DEBUG3]) { R200_STATECHANGE( rmesa, tam ); diff --git a/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.c b/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.c index 50d515401..aa982cfef 100644 --- a/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.c +++ b/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_ioctl.c @@ -62,11 +62,26 @@ static void radeonWaitForIdle( radeonContextPtr rmesa ); static int radeonFlushCmdBufLocked( radeonContextPtr rmesa, const char * caller ); +static void print_state_atom( struct radeon_state_atom *state ) +{ + int i; + + fprintf(stderr, "emit %s/%d\n", state->name, state->cmd_size); + + if (RADEON_DEBUG & DEBUG_VERBOSE) + for (i = 0 ; i < state->cmd_size ; i++) + fprintf(stderr, "\t%s[%d]: %x\n", state->name, i, state->cmd[i]); + +} + static void radeonSaveHwState( radeonContextPtr rmesa ) { struct radeon_state_atom *atom; char * dest = rmesa->backup_store.cmd_buf; + if (RADEON_DEBUG & DEBUG_STATE) + fprintf(stderr, "%s\n", __FUNCTION__); + rmesa->backup_store.cmd_used = 0; foreach( atom, &rmesa->hw.atomlist ) { @@ -75,10 +90,14 @@ static void radeonSaveHwState( radeonContextPtr rmesa ) memcpy( dest, atom->cmd, size); dest += size; rmesa->backup_store.cmd_used += size; + if (RADEON_DEBUG & DEBUG_STATE) + print_state_atom( atom ); } } assert( rmesa->backup_store.cmd_used <= RADEON_CMD_BUF_SZ ); + if (RADEON_DEBUG & DEBUG_STATE) + fprintf(stderr, "Returning to radeonEmitState\n"); } /* At this point we were in FlushCmdBufLocked but we had lost our context, so @@ -88,7 +107,7 @@ static void radeonSaveHwState( radeonContextPtr rmesa ) */ static void radeonBackUpAndEmitLostStateLocked( radeonContextPtr rmesa ) { - GLuint nr_released_bufs, saved_cmd_used; + GLuint nr_released_bufs; struct radeon_store saved_store; if (rmesa->backup_store.cmd_used == 0) @@ -103,9 +122,7 @@ static void radeonBackUpAndEmitLostStateLocked( radeonContextPtr rmesa ) saved_store = rmesa->store; rmesa->dma.nr_released_bufs = 0; rmesa->store = rmesa->backup_store; - saved_cmd_used = rmesa->backup_store.cmd_used; radeonFlushCmdBufLocked( rmesa, __FUNCTION__ ); - rmesa->backup_store.cmd_used = saved_cmd_used; rmesa->dma.nr_released_bufs = nr_released_bufs; rmesa->store = saved_store; } @@ -114,18 +131,6 @@ static void radeonBackUpAndEmitLostStateLocked( radeonContextPtr rmesa ) * Kernel command buffer handling */ -static void print_state_atom( struct radeon_state_atom *state ) -{ - int i; - - fprintf(stderr, "emit %s/%d\n", state->name, state->cmd_size); - - if (RADEON_DEBUG & DEBUG_VERBOSE) - for (i = 0 ; i < state->cmd_size ; i++) - fprintf(stderr, "\t%s[%d]: %x\n", state->name, i, state->cmd[i]); - -} - /* The state atoms will be emitted in the order they appear in the atom list, * so this step is important. */ @@ -1016,7 +1021,14 @@ static void radeonClear( GLcontext *ctx, GLbitfield mask, GLboolean all, __FUNCTION__, all, cx, cy, cw, ch ); } - RADEON_FIREVERTICES( rmesa ); + { + LOCK_HARDWARE( rmesa ); + UNLOCK_HARDWARE( rmesa ); + if ( dPriv->numClipRects == 0 ) + return; + } + + radeonFlush( ctx ); if ( mask & DD_FRONT_LEFT_BIT ) { flags |= RADEON_FRONT; diff --git a/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c b/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c index a3b2047bc..38bc4ebbc 100644 --- a/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c +++ b/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_screen.c @@ -87,11 +87,14 @@ static const GLuint __driNConfigOptions = 10; #define PCI_CHIP_RADEON_QZ 0x515A #define PCI_CHIP_RADEON_LW 0x4C57 /* mobility 7 - has tcl */ +#define PCI_CHIP_RADEON_LX 0x4C58 /* mobility FireGL 7800 m7 */ #define PCI_CHIP_RADEON_LY 0x4C59 #define PCI_CHIP_RADEON_LZ 0x4C5A #define PCI_CHIP_RV200_QW 0x5157 /* Radeon 7500 - not an R200 at all */ +#define PCI_CHIP_RV200_QX 0x5158 + /* IGP Chipsets */ #define PCI_CHIP_RS100_4136 0x4136 #define PCI_CHIP_RS200_4137 0x4137 @@ -309,7 +312,9 @@ radeonScreenPtr radeonCreateScreen( __DRIscreenPrivate *sPriv ) case PCI_CHIP_RADEON_QF: case PCI_CHIP_RADEON_QG: case PCI_CHIP_RV200_QW: + case PCI_CHIP_RV200_QX: case PCI_CHIP_RADEON_LW: + case PCI_CHIP_RADEON_LX: screen->chipset |= RADEON_CHIPSET_TCL; case PCI_CHIP_RADEON_QY: case PCI_CHIP_RADEON_QZ: diff --git a/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.c b/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.c index e86204419..35720fd65 100644 --- a/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.c +++ b/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_swtcl.c @@ -564,9 +564,12 @@ static void *radeon_alloc_elts( radeonContextPtr rmesa, int nr ) #define EMIT_ELT(offset, x) do { \ int off = offset + ( ( (GLuint)dest & 0x2 ) >> 1 ); \ GLushort *des = (GLushort *)( (GLuint)dest & ~0x2 ); \ - (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); } while (0) + (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); \ + (void)rmesa; } while (0) #else -#define EMIT_ELT(offset, x) (dest)[offset] = (GLushort) (x) +#define EMIT_ELT(offset, x) do { \ + (dest)[offset] = (GLushort) (x); \ + (void)rmesa; } while (0) #endif #define EMIT_TWO_ELTS(offset, x, y) *(GLuint *)(dest+offset) = ((y)<<16)|(x); #define INCR_ELTS( nr ) dest += nr diff --git a/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.c b/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.c index 6c121974e..760c9a034 100644 --- a/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.c +++ b/extras/Mesa/src/mesa/drivers/dri/radeon/radeon_tcl.c @@ -169,7 +169,7 @@ static GLushort *radeonAllocElts( radeonContextPtr rmesa, GLuint nr ) * discrete and there are no intervening state changes. (Somewhat * duplicates changes to DrawArrays code) */ -static void EMIT_PRIM( GLcontext *ctx, +static void radeonEmitPrim( GLcontext *ctx, GLenum prim, GLuint hwprim, GLuint start, @@ -194,7 +194,9 @@ static void EMIT_PRIM( GLcontext *ctx, count - start ); } - +#define EMIT_PRIM( ctx, prim, hwprim, start, count ) do { \ + radeonEmitPrim( ctx, prim, hwprim, start, count ); \ + (void) rmesa; } while (0) /* Try & join small primitives */ @@ -214,9 +216,12 @@ static void EMIT_PRIM( GLcontext *ctx, #define EMIT_ELT(dest, offset, x) do { \ int off = offset + ( ( (GLuint)dest & 0x2 ) >> 1 ); \ GLushort *des = (GLushort *)( (GLuint)dest & ~0x2 ); \ - (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); } while (0) + (des)[ off + 1 - 2 * ( off & 1 ) ] = (GLushort)(x); \ + (void)rmesa; } while (0) #else -#define EMIT_ELT(dest, offset, x) (dest)[offset] = (GLushort) (x) +#define EMIT_ELT(dest, offset, x) do { \ + (dest)[offset] = (GLushort) (x); \ + (void)rmesa; } while (0) #endif #define EMIT_TWO_ELTS(dest, offset, x, y) *(GLuint *)(dest+offset) = ((y)<<16)|(x); diff --git a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.c b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.c index 4ebf393ac..a994ee7e3 100644 --- a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.c +++ b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.c @@ -136,6 +136,110 @@ static const GLubyte *viaGetString(GLcontext *ctx, GLenum name) } } + +/** + * Calculate a width that satisfies the hardware's alignment requirements. + * On the Unichrome hardware, each scanline must be aligned to a multiple of + * 16 pixels. + * + * \param width Minimum buffer width, in pixels. + * + * \returns A pixel width that meets the alignment requirements. + */ +static __inline__ unsigned +buffer_align( unsigned width ) +{ + return (width + 0x0f) & ~0x0f; +} + + +/** + * Calculate the framebuffer parameters for all buffers (front, back, depth, + * and stencil) associated with the specified context. + * + * \warning + * This function also calls \c AllocateBuffer to actually allocate the + * buffers. + * + * \sa AllocateBuffer + */ +static GLboolean +calculate_buffer_parameters( viaContextPtr vmesa ) +{ + const unsigned shift = vmesa->viaScreen->bitsPerPixel / 16; + const unsigned extra = (vmesa->drawType == GLX_PBUFFER_BIT) ? 0 : 32; + unsigned w; + unsigned h; + + if (vmesa->drawType == GLX_PBUFFER_BIT) { + w = vmesa->driDrawable->w; + h = vmesa->driDrawable->h; + } + else { + w = vmesa->viaScreen->width; + h = vmesa->viaScreen->height; + + vmesa->front.offset = 0; + vmesa->front.map = (char *) vmesa->driScreen->pFB; + } + + vmesa->front.pitch = buffer_align( w ) << shift; + vmesa->front.size = vmesa->front.pitch * h; + + + /* Allocate back-buffer */ + + vmesa->back.pitch = (buffer_align( vmesa->driDrawable->w ) << shift) + + extra; + vmesa->back.size = vmesa->back.pitch * vmesa->driDrawable->h; + +#ifdef DEBUG + if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent backbuffer: w = %d h = %d bpp = %d sizs = %d\n", + vmesa->back.pitch, + vmesa->driDrawable->h, + 8 << shift, + vmesa->back.size); +#endif + + /* Allocate depth-buffer */ + if ( vmesa->hasStencil || vmesa->hasDepth ) { + const unsigned dShift = (vmesa->hasStencil) + ? 2 : (vmesa->depthBits / 16); + + vmesa->depth.pitch = (buffer_align( vmesa->driDrawable->w ) << dShift) + + extra; + vmesa->depth.bpp = 8 << dShift; + vmesa->depth.size = vmesa->depth.pitch * vmesa->driDrawable->h; + } + else { + (void) memset( & vmesa->depth, 0, sizeof( vmesa->depth ) ); + } + +#ifdef DEBUG + if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent depthbuffer: w = %d h = %d bpp = %d sizs = %d\n", + vmesa->depth.pitch, + vmesa->driDrawable->h, + vmesa->depth.bpp, + vmesa->depth.size); +#endif + + /*=* John Sheng [2003.5.31] flip *=*/ + if( (vmesa->viaScreen->width == vmesa->driDrawable->w) + && (vmesa->viaScreen->height == vmesa->driDrawable->h) ) { + vmesa->doPageFlip = GL_FALSE; + vmesa->currentPage = 0; + vmesa->back.pitch = vmesa->front.pitch; + } + + if (!AllocateBuffer(vmesa)) { + FREE(vmesa); + return GL_FALSE; + } + + return GL_TRUE; +} + + void viaReAllocateBuffers(GLframebuffer *drawbuffer) { GLcontext *ctx; @@ -152,95 +256,11 @@ void viaReAllocateBuffers(GLframebuffer *drawbuffer) vmesa->driDrawable->w = ctx->DrawBuffer->Width; vmesa->driDrawable->h = ctx->DrawBuffer->Height; + LOCK_HARDWARE(vmesa); - - /* Allocate back & depth buffer */ - { - int w, h, bpp; - w = vmesa->driDrawable->w; - h = vmesa->driDrawable->h; - /* back buffer */ - bpp = vmesa->viaScreen->bitsPerPixel; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "driScreen->fbBPP = %d\n", bpp); -#endif - if (bpp == 32) { - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4 + 8; - vmesa->back.size = w * h * bpp / 8; - vmesa->back.pitch = w << 2; - } - else { - w = BUFFER_ALIGN_WIDTH(w * 2, BUFFER_ALIGNMENT) / 2 + 16; - vmesa->back.size = w * h * bpp / 8; - vmesa->back.pitch = w << 1; - } -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "resizebuffer backbuffer: w = %d h = %d bpp = %d sizs = %d\n", - w, h, bpp, vmesa->back.size); -#endif - /* depth buffer */ - w = vmesa->driDrawable->w; - if (vmesa->hasDepth && vmesa->hasStencil) { - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4 + 8; - vmesa->depth.size = w * h * 4; - vmesa->depth.pitch = w << 2; - vmesa->depth.bpp = 32; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "depthBits = 24\n"); - if (VIA_DEBUG) fprintf(stderr, "StencilBits = 8\n"); -#endif - } - else if (vmesa->hasDepth) { - /*=* John Sheng [2003.6.16] patch viewperf drv-08 draw nothing */ - /*if(vmesa->viaScreen->bitsPerPixel == 32)*/ - /*vmesa->depthBits = 16;*/ - - if (vmesa->depthBits == 16) { - w = BUFFER_ALIGN_WIDTH(w * 2, BUFFER_ALIGNMENT) / 2 + 16; - vmesa->depth.size = w * h * 2; - vmesa->depth.pitch = w << 1; - vmesa->depth.bpp = 16; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "depthBits = 16\n"); -#endif - } - else { - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4 + 8; - vmesa->depth.size = w * h * 4; - vmesa->depth.pitch = w << 2; - vmesa->depth.bpp = 32; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "depthBits = 32\n"); -#endif - } - } - else if (vmesa->hasStencil) { - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4 + 8; - vmesa->depth.size = w * h * 4; - vmesa->depth.pitch = w << 2; - vmesa->depth.bpp = 32; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "StencilBits = 8\n"); -#endif - } -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "resizebuffer depthbuffer: w = %d h = %d bpp = %d sizs = %d\n", - w, h, vmesa->depth.bpp, vmesa->depth.size); -#endif - /*=* John Sheng [2003.5.31] flip *=*/ - { - if(vmesa->viaScreen->width == vmesa->driDrawable->w && - vmesa->viaScreen->height == vmesa->driDrawable->h) { - vmesa->back.pitch = vmesa->front.pitch; - vmesa->back.size = vmesa->front.size; - } - } - - if (!AllocateBuffer(vmesa)) { - FREE(vmesa); - } - } + calculate_buffer_parameters( vmesa ); UNLOCK_HARDWARE(vmesa); + #ifdef DEBUG if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); #endif @@ -440,6 +460,8 @@ viaCreateContext(const __GLcontextModes *mesaVis, ctx->Const.MaxTextureLevels = 11; ctx->Const.MaxTextureUnits = 2; + ctx->Const.MaxTextureImageUnits = ctx->Const.MaxTextureUnits; + ctx->Const.MaxTextureCoordUnits = ctx->Const.MaxTextureUnits; ctx->Const.MinLineWidth = 1.0; ctx->Const.MinLineWidthAA = 1.0; @@ -567,12 +589,12 @@ viaCreateContext(const __GLcontextModes *mesaVis, if (VIA_DEBUG) fprintf(stderr, "%s - out\n", __FUNCTION__); #endif { - GLboolean saam; - int count = 0, fbSize; #ifndef USE_XINERAMA vmesa->saam = 0; #else - saam = XineramaIsActive(vmesa->display); + GLboolean saam = XineramaIsActive(vmesa->display); + int count = 0, fbSize; + if (saam && vmesa->viaScreen->drixinerama) { vmesa->xsi = XineramaQueryScreens(vmesa->display, &count); /* Test RightOf or Down */ @@ -716,8 +738,10 @@ void viaXMesaSetBackClipRects(viaContextPtr vmesa) void viaXMesaWindowMoved(viaContextPtr vmesa) { GLuint bytePerPixel = vmesa->viaScreen->bitsPerPixel >> 3; +#ifdef USE_XINERAMA GLuint side = 0; __DRIdrawablePrivate *dPriv = vmesa->driDrawable; +#endif switch (vmesa->glCtx->Color._DrawDestMask) { case __GL_FRONT_BUFFER_MASK: @@ -904,178 +928,22 @@ viaMakeCurrent(__DRIcontextPrivate *driContextPriv, fprintf(stderr, "driContextPriv = %08x\n", (GLuint)driReadPriv); } #endif - + if (driContextPriv) { viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate; + current_mesa = vmesa; - - vmesa->driDrawable = driDrawPriv; - if (vmesa->drawType == GLX_PBUFFER_BIT) { - int w, h, bpp; - - w = vmesa->driDrawable->w; - h = vmesa->driDrawable->h; - bpp = vmesa->viaScreen->bitsPerPixel; - if (bpp == 32) { - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4; - vmesa->front.size = w * h * bpp / 8; - vmesa->front.pitch = w << 2; - } - else { - w = BUFFER_ALIGN_WIDTH(w * 2, BUFFER_ALIGNMENT) / 2; - vmesa->front.size = w * h * bpp / 8; - vmesa->front.pitch = w << 1; - } - } - /*=* John Sheng [2003.6.20] fix resolution 720x480/720x576 front pitch error *=*/ - else { - GLuint w; - GLuint h; - GLuint bpp; - bpp = vmesa->viaScreen->bitsPerPixel; - h = vmesa->viaScreen->height; - w = vmesa->viaScreen->width; - if (bpp == 0x20) { - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4; - vmesa->front.size = w * h * bpp / 8; - vmesa->front.pitch = w << 2; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "viaScreen->bitsPerPixel = %d\n", 32); -#endif - } - else if (bpp == 0x10) { - w = BUFFER_ALIGN_WIDTH(w * 2, BUFFER_ALIGNMENT) / 2; - vmesa->front.size = w * h * bpp / 8; - vmesa->front.pitch = w << 1; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "viaScreen->bitsPerPixel = %d\n", 16); -#endif - } - vmesa->front.offset = 0; - vmesa->front.map = (char *) vmesa->driScreen->pFB; - vmesa->front.size = w * h * vmesa->viaScreen->bitsPerPixel /8; - } - - /* Allocate back & depth buffer */ - { - int w, h, bpp; - - w = vmesa->driDrawable->w; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent: w = %d\n", w); -#endif - h = vmesa->driDrawable->h; - - /* back buffer */ - bpp = vmesa->viaScreen->bitsPerPixel; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "driScreen->fbBPP = %d\n", bpp); -#endif - if (bpp == 32) { - if (vmesa->drawType == GLX_PBUFFER_BIT) - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4; - else - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4 + 8; - - vmesa->back.size = w * h * bpp / 8; - vmesa->back.pitch = w << 2; - } - else { - if (vmesa->drawType == GLX_PBUFFER_BIT) - w = BUFFER_ALIGN_WIDTH(w * 2, BUFFER_ALIGNMENT) / 2; - else - w = BUFFER_ALIGN_WIDTH(w * 2, BUFFER_ALIGNMENT) / 2 + 16; - - vmesa->back.size = w * h * bpp / 8; - vmesa->back.pitch = w << 1; - } -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent backbuffer: w = %d h = %d bpp = %d sizs = %d\n", - w, h, bpp, vmesa->back.size); -#endif - /* depth buffer */ - w = vmesa->driDrawable->w; - - if (vmesa->hasDepth && vmesa->hasStencil) { - if (vmesa->drawType == GLX_PBUFFER_BIT) - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4; - else - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4 + 8; - - vmesa->depth.size = w * h * 4; - vmesa->depth.pitch = w << 2; - vmesa->depth.bpp = 32; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "depthBits = 24\n"); - if (VIA_DEBUG) fprintf(stderr, "StencilBits = 8\n"); -#endif - } - else if (vmesa->hasDepth) { - /*=* John Sheng [2003.6.16] patch viewperf drv-08 draw nothing */ - /*if(vmesa->viaScreen->bitsPerPixel == 32)*/ - /*vmesa->depthBits = 16;*/ - - if (vmesa->depthBits == 16) { - if (vmesa->drawType == GLX_PBUFFER_BIT) - w = BUFFER_ALIGN_WIDTH(w * 2, BUFFER_ALIGNMENT) / 2; - else - w = BUFFER_ALIGN_WIDTH(w * 2, BUFFER_ALIGNMENT) / 2 + 16; - - vmesa->depth.size = w * h * 2; - vmesa->depth.pitch = w << 1; - vmesa->depth.bpp = 16; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "depthBits = 16\n"); -#endif - } - else { - if (vmesa->drawType == GLX_PBUFFER_BIT) - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4; - else - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4 + 8; - - vmesa->depth.size = w * h * 4; - vmesa->depth.pitch = w << 2; - vmesa->depth.bpp = 32; #ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "depthBits = 32\n"); -#endif - } - } - else if (vmesa->hasStencil) { - if (vmesa->drawType == GLX_PBUFFER_BIT) - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4; - else - w = BUFFER_ALIGN_WIDTH(w * 4, BUFFER_ALIGNMENT) / 4 + 8; - - vmesa->depth.size = w * h * 4; - vmesa->depth.pitch = w << 2; - vmesa->depth.bpp = 32; -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "StencilBits = 8\n"); + if (VIA_DEBUG) fprintf(stderr, "viaScreen->bitsPerPixel = %d\n", viaScreen->bitsPerPixel); + if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent: w = %d\n", vmesa->driDrawable->w); #endif - } -#ifdef DEBUG - if (VIA_DEBUG) fprintf(stderr, "viaMakeCurrent depthbuffer: w = %d h = %d bpp = %d sizs = %d\n", - w, h, vmesa->depth.bpp, vmesa->depth.size); -#endif - /*=* John Sheng [2003.5.31] flip *=*/ - { - viaContextPtr vmesa = (viaContextPtr)driContextPriv->driverPrivate; - if(vmesa->viaScreen->width == vmesa->driDrawable->w && - vmesa->viaScreen->height == vmesa->driDrawable->h) { - vmesa->doPageFlip = GL_FALSE; - vmesa->currentPage = 0; - vmesa->back.pitch = vmesa->front.pitch; - } - } - if (!AllocateBuffer(vmesa)) { - FREE(vmesa); - return GL_FALSE; - } + vmesa->driDrawable = driDrawPriv; + if ( ! calculate_buffer_parameters( vmesa ) ) { + return GL_FALSE; } + _mesa_make_current2(vmesa->glCtx, (GLframebuffer *)driDrawPriv->driverPrivate, (GLframebuffer *)driReadPriv->driverPrivate); diff --git a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.h b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.h index 5efd9a022..5b2855a83 100644 --- a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.h +++ b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_context.h @@ -75,10 +75,7 @@ typedef struct via_texture_object_t *viaTextureObjectPtr; #define TAG(x) via##x #include "tnl_dd/t_dd_vertex.h" #undef TAG -#define BUFFER_ALIGNMENT 32 -#define BUFFER_ALIGN_WIDTH1(w, a) (((w) + ((a) - 1)) & ~((a) - 1)) -#define BUFFER_ALIGN_WIDTH(w, a) (((w) & ((a) - 1)) ? BUFFER_ALIGN_WIDTH1(w, a) : (w)) -#define BUFFER_ALIGN_ADDRESS(p, a) ((GLvoid *)(((GLint)(p)) + ((a)-1) & ~((a)-1))) + #define RightOf 1 #define LeftOf 2 #define Down 4 diff --git a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.c b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.c index eaa5a726e..9f2ce638a 100644 --- a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.c +++ b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.c @@ -313,7 +313,6 @@ void viaCopyBuffer(const __DRIdrawablePrivate *dPriv) #ifdef DEBUG if (VIA_DEBUG) fprintf(stderr, "%s SwapPBuffers\n", __FUNCTION__); #endif /*=* [DBG] for pbuffer *=*/ - /*viaDoSwapBufferSoftFront(vmesa);*/ } else { GLuint scrn = 0; @@ -1436,83 +1435,7 @@ void viaDoSwapPBuffers(viaContextPtr vmesa) #endif } -void viaDoSwapBufferSoft(viaContextPtr vmesa) -{ - GLuint nFrontPitch; - GLuint nBackPitch; - GLuint nFrontBase, nBackBase; - GLuint i, j; - GLubyte *by, *fy; - GLuint w; - - w = vmesa->viaScreen->width; - w = BUFFER_ALIGN_WIDTH(w, BUFFER_ALIGNMENT); - - if (vmesa->viaScreen->bitsPerPixel == 0x20) - nFrontPitch = w << 2; - else - nFrontPitch = w << 1; - - nBackPitch = vmesa->back.pitch; - - /* Caculate Base */ - nFrontBase = (GLuint) vmesa->driScreen->pFB; - nBackBase = ((GLuint) vmesa->back.offset) + ((GLuint) vmesa->driScreen->pFB); - by = (GLubyte *) nBackBase; - fy = (GLubyte *) nFrontBase; - - viaFlushPrimsLocked(vmesa); - - for (i = 0; i < vmesa->driDrawable->h; i++) { - fy = (GLubyte *)(nFrontBase + i * nFrontPitch); - for (j = 0; j < nBackPitch; j++) { - *((GLubyte*)fy) = *((GLubyte*)by); - fy = fy + 1; - by = by + 1; - } - - } - -} -void viaDoSwapBufferSoftFront(viaContextPtr vmesa) -{ - GLuint nFrontPitch; - GLuint nBackPitch; - GLuint nFrontBase, nBackBase; - GLuint i, j; - GLubyte *by, *fy; - GLuint w; - - w = vmesa->viaScreen->width; - w = BUFFER_ALIGN_WIDTH(w, BUFFER_ALIGNMENT); - - if (vmesa->viaScreen->bitsPerPixel == 0x20) - nFrontPitch = w << 2; - else - nFrontPitch = w << 1; - - nBackPitch = vmesa->front.pitch; - - /* Caculate Base */ - nFrontBase = (GLuint) vmesa->driScreen->pFB; - nBackBase = ((GLuint) vmesa->front.offset) + ((GLuint) vmesa->driScreen->pFB); - by = (GLubyte *) nBackBase; - fy = (GLubyte *) nFrontBase; - - viaFlushPrimsLocked(vmesa); - - for (i = 0; i < vmesa->driDrawable->h; i++) { - fy = (GLubyte *)(nFrontBase + i * nFrontPitch); - for (j = 0; j < nBackPitch; j++) { - *((GLubyte*)fy) = *((GLubyte*)by); - fy = fy + 1; - by = by + 1; - } - - } - -} int flush_agp(viaContextPtr vmesa, drm_via_flush_agp_t* agpCmd) { GLuint *pnAGPCurrentPhysStart; diff --git a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.h b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.h index e9030e630..3bdd6c359 100644 --- a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.h +++ b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_ioctl.h @@ -47,8 +47,6 @@ void viaFillStencilBuffer(viaContextPtr vmesa, GLuint pixel); void viaFillStencilDepthBuffer(viaContextPtr vmesa, GLuint pixel); void viaDoSwapBuffers(viaContextPtr vmesa); void viaDoSwapBuffersSaam(viaContextPtr vmesa); -void viaDoSwapBufferSoft(viaContextPtr vmesa); -void viaDoSwapBufferSoftFront(viaContextPtr vmesa); void viaDoSwapPBuffers(viaContextPtr vmesa); int flush_agp(viaContextPtr vmesa, drm_via_flush_agp_t* agpCmd); diff --git a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_texcombine.c b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_texcombine.c index 9559cb30c..bdd3018e3 100644 --- a/extras/Mesa/src/mesa/drivers/dri/unichrome/via_texcombine.c +++ b/extras/Mesa/src/mesa/drivers/dri/unichrome/via_texcombine.c @@ -20,9 +20,13 @@ * 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 via_texcombine.c + * Calculate texture combine hardware state. * - * Authors: - * Ian Romanick <idr@us.ibm.com> + * \author Ian Romanick <idr@us.ibm.com> */ #include <stdio.h> @@ -106,8 +110,8 @@ viaTexCombineState( viaContextPtr vmesa, unsigned alpha = 0; unsigned bias = 0; unsigned op = 0; - unsigned a_shift = combine->ScaleShiftRGB; - unsigned c_shift = combine->ScaleShiftA; + unsigned a_shift = combine->ScaleShiftA; + unsigned c_shift = combine->ScaleShiftRGB; unsigned i; unsigned constant_color[3]; unsigned ordered_constant_color[4]; |