diff options
author | kem <kem> | 2001-04-05 18:27:01 +0000 |
---|---|---|
committer | kem <kem> | 2001-04-05 18:27:01 +0000 |
commit | a80b3a6025d8044b0cd94799efb4814ccc19a834 (patch) | |
tree | 3df856e6629a7d3c21a3663a2744da994ab66c69 | |
parent | 29ae20bc83cd9fcb02cfaa9d1f0ce9be6e827536 (diff) |
- Reintegrate PPC support from old pcigart branchati-pcigart-1-0-0-20010405-freeze
19 files changed, 350 insertions, 121 deletions
diff --git a/xc/config/cf/host.def b/xc/config/cf/host.def new file mode 100644 index 000000000..13da5d4a9 --- /dev/null +++ b/xc/config/cf/host.def @@ -0,0 +1,62 @@ + +#define DefaultGcc2AxpOpt -O2 -mcpu=ev6 +#define DefaultGcc2AxpOpt -O2 -mcpu=750 +#define DefaultGcc2i386Opt -O2 +#ifdef AlphaArchitecture +#define LibraryCDebugFlags -O2 -mcpu=ev6 +#else +#ifdef PpcArchitecture +#define LibraryCDebugFlags -O2 -mcpu=750 +#else +#define LibraryCDebugFlags -O2 +#endif +#endif +#define BuildServersOnly YES +#define BuildXFree86ConfigTools NO +#define XF86CardDrivers vga tdfx i810 mga ati glint +#define LinuxDistribution LinuxRedHat +#define GccWarningOptions -Wall -Wpointer-arith -Wstrict-prototypes \ + -Wmissing-prototypes -Wmissing-declarations \ + -Wnested-externs +#define DefaultCCOptions -ansi GccWarningOptions -pipe -g +#define NormalLibGlx NO + +#define BuildXF86DRI YES +#define HasGlide3 YES + +#ifdef i386Architecture +#define MesaUse3DNow YES +#if HasKatmaiSupport +# define MesaUseKatmai YES +#endif +#endif + +/* To do profiling of the dynamically loaded 'xyz_dri.so' object, turn + * this on. + * Use 'xc/lib/GL/makeprofile.sh' to make it work. + */ +/* #define GlxSoProf YES */ + +#ifdef GlxSoProf +# undef DefaultCCOptions +# define DefaultCCOptions -ansi GccWarningOptions -pipe -g -p +#endif + +/* Optionally turn these on for debugging */ +/* #define GlxBuiltInTdfx YES */ +/* #define GlxBuiltInI810 YES */ +/* #define GlxBuiltInMga YES */ +/* #define GlxBuiltInR128 YES */ +/* #define GlxBuiltInRadeon YES */ +/* #define DoLoadableServer NO */ + +/* Optionally turn this on to change the place where you install the build */ +/* #define ProjectRoot /usr/X11R6-DRI */ + +/* Optionally turn this on to force the kernel modules to build */ +/* #define BuildXF86DRM YES */ + +#define XnestServer NO +#define XVirtualFramebufferServer NO +#define XprtServer NO + diff --git a/xc/lib/GL/mesa/src/drv/Imakefile b/xc/lib/GL/mesa/src/drv/Imakefile index 6639512c2..dcd78c5e8 100644 --- a/xc/lib/GL/mesa/src/drv/Imakefile +++ b/xc/lib/GL/mesa/src/drv/Imakefile @@ -52,7 +52,7 @@ SUBDIRS += sis SUBDIRS += tdfx #endif -#elif defined(AlphaArchitecture) +#elif defined(AlphaArchitecture) || defined(PpcArchitecture) SUBDIRS += common SUBDIRS += gamma diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.h b/xc/lib/GL/mesa/src/drv/r128/r128_context.h index 8c5e2fdfc..f0ea2a14e 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_context.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.h @@ -88,10 +88,16 @@ typedef struct r128_context *r128ContextPtr; #define R128_BLEND_ENV_COLOR 0x1 #define R128_BLEND_MULTITEX 0x2 -/* Subpixel offsets for window coordinates: +/* Subpixel offsets for window coordinates (triangles): */ -#define SUBPIXEL_X (-0.125F) -#define SUBPIXEL_Y ( 0.375F) +#define SUBPIXEL_X (0.0F) +#define SUBPIXEL_Y (0.125F) + +/* Offset for points: + */ +#define PNT_X_OFFSET ( 0.125F) +#define PNT_Y_OFFSET (-0.125F) + typedef void (*r128_interp_func)( GLfloat t, GLfloat *result, @@ -127,10 +133,12 @@ struct r128_context { GLuint vc_format; GLfloat depth_scale; - CARD32 Color; /* Current draw color */ - CARD32 ClearColor; /* Color used to clear color buffer */ - CARD32 ClearDepth; /* Value used to clear depth buffer */ - CARD32 ClearStencil; /* Value used to clear stencil */ + GLuint Color; /* Current draw color */ + GLuint ClearColor; /* Color used to clear color buffer */ + GLuint ClearDepth; /* Value used to clear depth buffer */ + GLuint ClearStencil; /* Value used to clear stencil */ + GLuint DepthMask; + GLuint StencilMask; /* Map GL texture units onto hardware */ @@ -210,6 +218,8 @@ struct r128_context { __DRIscreenPrivate *driScreen; /* DRI screen */ __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */ + int lastStamp; /* mirror driDrawable->lastStamp */ + drmContext hHWContext; drmLock *driHwLock; int driFd; @@ -245,14 +255,32 @@ extern r128ContextPtr r128MakeCurrent( r128ContextPtr oldCtx, r128ContextPtr newCtx, __DRIdrawablePrivate *dPriv ); +/* ================================================================ + * Byte ordering + */ +#include <endian.h> + +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define LE32_OUT( x, y ) do { x = y; } while (0) +#define LE32_OUT_FLOAT( x, y ) do { *(GLfloat *)&(x) = y; } while (0) +#else +#include <byteswap.h> +#define LE32_OUT( x, y ) do { x = bswap_32( y ); } while (0) +#define LE32_OUT_FLOAT( x, y ) \ +do { \ + GLuint __tmp; \ + *(GLfloat *)&__tmp = y; \ + x = bswap_32( __tmp ); \ +} while (0) +#endif /* ================================================================ * Debugging: */ -#define DEBUG 0 +#define DO_DEBUG 0 #define ENABLE_PERF_BOXES 0 -#if DEBUG +#if DO_DEBUG extern int R128_DEBUG; #else #define R128_DEBUG 0 diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_dd.c b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c index 60b9c8606..5b595120e 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_dd.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c @@ -45,7 +45,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "X86/common_x86_asm.h" #endif -#define R128_DATE "20010326" +#define R128_DATE "20010405" /* Return the width and height of the current color buffer. diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c b/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c index 51a68f53e..426425583 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c @@ -316,6 +316,11 @@ static int r128WaitForFrameCompletion( r128ContextPtr rmesa ) #else frame = INREG( R128_LAST_FRAME_REG ); #endif + + if ( 0 ) + fprintf( stderr, " last=0x%08x frame=0x%08x\n", + rmesa->sarea->last_frame, frame ); + if ( rmesa->sarea->last_frame - frame <= R128_MAX_OUTSTANDING ) { break; } diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tex.c b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c index f518720f5..efdd025f4 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_tex.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c @@ -30,6 +30,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Authors: * Gareth Hughes <gareth@valinux.com> * Kevin E. Martin <martin@valinux.com> + * Michel Dänzer <michdaen@iiic.ethz.ch> * */ @@ -572,8 +573,8 @@ static void r128ConvertTexture16bpp( CARD32 *dst, for ( i = 0 ; i < height ; i++ ) { src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 4; for ( j = width >> 1 ; j ; j-- ) { - *dst++ = ((R128PACKCOLOR4444( src[0], src[1], src[2], src[3] )) | - (R128PACKCOLOR4444( src[4], src[5], src[6], src[7] ) << 16)); + *dst++ = R128PACKCOLORS4444( src[0], src[1], src[2], src[3], + src[4], src[5], src[6], src[7] ); src += 8; } } @@ -583,8 +584,8 @@ static void r128ConvertTexture16bpp( CARD32 *dst, for ( i = 0 ; i < height ; i++ ) { src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 3; for ( j = width >> 1 ; j ; j-- ) { - *dst++ = ((R128PACKCOLOR565( src[0], src[1], src[2] )) | - (R128PACKCOLOR565( src[3], src[4], src[5] ) << 16)); + *dst++ = R128PACKCOLORS565( src[0], src[1], src[2], + src[3], src[4], src[5] ); src += 6; } } @@ -594,8 +595,8 @@ static void r128ConvertTexture16bpp( CARD32 *dst, for ( i = 0 ; i < height ; i++ ) { src = (CARD8 *)image->Data + ((y + i) * pitch + x); for ( j = width >> 1 ; j ; j-- ) { - *dst++ = ((R128PACKCOLOR4444( 0xff, 0xff, 0xff, src[0] )) | - (R128PACKCOLOR4444( 0xff, 0xff, 0xff, src[1] ) << 16)); + *dst++ = R128PACKCOLORS4444( 0xff, 0xff, 0xff, src[0], + 0xff, 0xff, 0xff, src[1] ); src += 2; } } @@ -605,8 +606,8 @@ static void r128ConvertTexture16bpp( CARD32 *dst, for ( i = 0 ; i < height ; i++ ) { src = (CARD8 *)image->Data + ((y + i) * pitch + x) * 2; for ( j = width >> 1 ; j ; j-- ) { - *dst++ = ((R128PACKCOLOR4444( src[0], src[0], src[0], src[1] )) | - (R128PACKCOLOR4444( src[2], src[2], src[2], src[3] ) << 16)); + *dst++ = R128PACKCOLORS4444( src[0], src[0], src[0], src[1], + src[2], src[2], src[2], src[3] ); src += 4; } } @@ -877,7 +878,8 @@ int r128UploadTexImages( r128ContextPtr rmesa, r128TexObjPtr t ) t->memBlock = mmAllocMem( rmesa->texHeap[heap], t->totalSize, 12, 0 ); /* Try AGP before kicking anything out of local mem */ - if ( !t->memBlock && heap == R128_CARD_HEAP ) { + if ( !rmesa->r128Screen->IsPCI && + !t->memBlock && heap == R128_CARD_HEAP ) { t->memBlock = mmAllocMem( rmesa->texHeap[R128_AGP_HEAP], t->totalSize, 12, 0 ); @@ -1572,6 +1574,9 @@ static void r128DDTexSubImage( GLcontext *ctx, GLenum target, if ( t ) { if ( t->bound ) FLUSH_BATCH( rmesa ); +#if 0 + /* FIXME: Only upload textures if we already have space in the heap. + */ LOCK_HARDWARE( rmesa ); r128UploadSubImage( rmesa, t, level, xoffset, yoffset, width, height ); @@ -1579,6 +1584,9 @@ static void r128DDTexSubImage( GLcontext *ctx, GLenum target, /* Update the context state */ rmesa->setup.tex_cntl_c |= R128_TEX_CACHE_FLUSH; +#else + r128DestroyTexObj( rmesa, t ); +#endif rmesa->new_state |= R128_NEW_TEXTURE; } diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tex.h b/xc/lib/GL/mesa/src/drv/r128/r128_tex.h index e1f67a56d..a0090f389 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_tex.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.h @@ -74,6 +74,23 @@ extern void r128DDInitTextureFuncs( GLcontext *ctx ); #define R128PACKCOLOR4444( r, g, b, a ) \ ((((a) & 0xf0) << 8) | (((r) & 0xf0) << 4) | ((g) & 0xf0) | ((b) >> 4)) +#if __BYTE_ORDER == __LITTLE_ENDIAN +#define R128PACKCOLORS565( r0, g0, b0, r1, g1, b1 ) \ + ((R128PACKCOLOR565( r0, g0, b0 )) | \ + (R128PACKCOLOR565( r1, g1, b1 ) << 16)) +#define R128PACKCOLORS4444( r0, g0, b0, a0, r1, g1, b1, a1 ) \ + ((R128PACKCOLOR4444( r0, g0, b0, a0 )) | \ + (R128PACKCOLOR4444( r1, g1, b1, a1 ) << 16)) +#else +#define R128PACKCOLORS565( r0, g0, b0, r1, g1, b1 ) \ + ((R128PACKCOLOR565( r1, g1, b1 )) | \ + (R128PACKCOLOR565( r0, g0, b0 ) << 16)) +#define R128PACKCOLORS4444( r0, g0, b0, a0, r1, g1, b1, a1 ) \ + ((R128PACKCOLOR4444( r1, g1, b1, a1 )) | \ + (R128PACKCOLOR4444( r0, g0, b0, a0 ) << 16)) + +#endif + static __inline__ CARD32 r128PackColor( GLuint cpp, GLubyte r, GLubyte g, GLubyte b, GLubyte a ) diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tris.c b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c index 4d83e27e0..52d1ad032 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_tris.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c @@ -30,6 +30,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Authors: * Gareth Hughes <gareth@valinux.com> * Kevin E. Martin <martin@valinux.com> + * Michel Dänzer <michdaen@iiic.ethz.ch> * */ @@ -49,6 +50,7 @@ static struct { quad_func quad; } rast_tab[R128_MAX_TRIFUNC]; +#if __BYTE_ORDER == __LITTLE_ENDIAN #define R128_COLOR( to, from ) \ do { \ (to)[0] = (from)[2]; \ @@ -56,6 +58,15 @@ do { \ (to)[2] = (from)[0]; \ (to)[3] = (from)[3]; \ } while (0) +#else +#define R128_COLOR( to, from ) \ +do { \ + (to)[0] = (from)[3]; \ + (to)[1] = (from)[0]; \ + (to)[2] = (from)[1]; \ + (to)[3] = (from)[2]; \ +} while (0) +#endif static void r128_null_quad( GLcontext *ctx, GLuint v0, diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tris.h b/xc/lib/GL/mesa/src/drv/r128/r128_tris.h index 79b3fb69e..320ace740 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_tris.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.h @@ -56,7 +56,7 @@ static __inline void r128_draw_triangle( r128ContextPtr rmesa, r128VertexPtr v1, r128VertexPtr v2 ) { - int vertsize = rmesa->vertsize; + GLuint vertsize = rmesa->vertsize; CARD32 *vb = r128AllocVerticesInline( rmesa, 3 ); int j; @@ -80,15 +80,15 @@ static __inline void r128_draw_triangle( r128ContextPtr rmesa, : "memory" ); #else for ( j = 0 ; j < vertsize ; j++ ) - vb[j] = v0->ui[j]; + LE32_OUT( vb[j], v0->ui[j] ); vb += vertsize; for ( j = 0 ; j < vertsize ; j++ ) - vb[j] = v1->ui[j]; + LE32_OUT( vb[j], v1->ui[j] ); vb += vertsize; for ( j = 0 ; j < vertsize ; j++ ) - vb[j] = v2->ui[j]; + LE32_OUT( vb[j], v2->ui[j] ); #endif } @@ -98,7 +98,7 @@ static __inline void r128_draw_quad( r128ContextPtr rmesa, r128VertexPtr v2, r128VertexPtr v3 ) { - int vertsize = rmesa->vertsize; + GLuint vertsize = rmesa->vertsize; CARD32 *vb = r128AllocVerticesInline( rmesa, 6 ); int j; @@ -134,87 +134,110 @@ static __inline void r128_draw_quad( r128ContextPtr rmesa, : "memory" ); #else for ( j = 0 ; j < vertsize ; j++ ) - vb[j] = v0->ui[j]; + LE32_OUT( vb[j], v0->ui[j] ); vb += vertsize; for ( j = 0 ; j < vertsize ; j++ ) - vb[j] = v1->ui[j]; + LE32_OUT( vb[j], v1->ui[j] ); vb += vertsize; for ( j = 0 ; j < vertsize ; j++ ) - vb[j] = v3->ui[j]; + LE32_OUT( vb[j], v3->ui[j] ); vb += vertsize; for ( j = 0 ; j < vertsize ; j++ ) - vb[j] = v1->ui[j]; + LE32_OUT( vb[j], v1->ui[j] ); vb += vertsize; for ( j = 0 ; j < vertsize ; j++ ) - vb[j] = v2->ui[j]; + LE32_OUT( vb[j], v2->ui[j] ); vb += vertsize; for ( j = 0 ; j < vertsize ; j++ ) - vb[j] = v3->ui[j]; + LE32_OUT( vb[j], v3->ui[j] ); #endif } static __inline void r128_draw_line( r128ContextPtr rmesa, r128VertexPtr tmp0, r128VertexPtr tmp1, - float width ) + GLfloat width ) { #if 1 - int vertsize = rmesa->vertsize; + GLuint vertsize = rmesa->vertsize; CARD32 *vb = r128AllocVerticesInline( rmesa, 6 ); - float dx, dy, ix, iy; - int j; + GLfloat hw, dx, dy, ix, iy; + GLuint j; + GLfloat x0 = tmp0->v.x; + GLfloat y0 = tmp0->v.y; + GLfloat x1 = tmp1->v.x; + GLfloat y1 = tmp1->v.y; + + hw = 0.5F * width; + if (hw > 0.1F && hw < 0.5F) { + hw = 0.5F; + } + /* adjust vertices depending on line direction */ dx = tmp0->v.x - tmp1->v.x; dy = tmp0->v.y - tmp1->v.y; - - ix = width * .5; iy = 0; - - if ((ix<.5) && (ix>0.1)) ix = .5; /* I want to see lines with width - 0.5 also */ - if (dx * dx > dy * dy) { - iy = ix; ix = 0; + /* X-major line */ + ix = 0.0F; + iy = hw; + if (x1 < x0) { + x0 += 0.5F; + x1 += 0.5F; + } + y0 -= 0.5F; + y1 -= 0.5F; + } + else { + /* Y-major line */ + ix = hw; + iy = 0.0F; + if (y1 > y0) { + y0 -= 0.5F; + y1 -= 0.5F; + } + x0 += 0.5F; + x1 += 0.5F; } - *(float *)&vb[0] = tmp0->v.x - ix; - *(float *)&vb[1] = tmp0->v.y - iy; + LE32_OUT_FLOAT( vb[0], x0 - ix ); + LE32_OUT_FLOAT( vb[1], y0 - iy ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp0->ui[j]; + LE32_OUT( vb[j], tmp0->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp1->v.x + ix; - *(float *)&vb[1] = tmp1->v.y + iy; + LE32_OUT_FLOAT( vb[0], x1 + ix ); + LE32_OUT_FLOAT( vb[1], y1 + iy ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp1->ui[j]; + LE32_OUT( vb[j], tmp1->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp0->v.x + ix; - *(float *)&vb[1] = tmp0->v.y + iy; + LE32_OUT_FLOAT( vb[0], x0 + ix ); + LE32_OUT_FLOAT( vb[1], y0 + iy ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp0->ui[j]; + LE32_OUT( vb[j], tmp0->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp0->v.x - ix; - *(float *)&vb[1] = tmp0->v.y - iy; + LE32_OUT_FLOAT( vb[0], x0 - ix ); + LE32_OUT_FLOAT( vb[1], y0 - iy ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp0->ui[j]; + LE32_OUT( vb[j], tmp0->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp1->v.x - ix; - *(float *)&vb[1] = tmp1->v.y - iy; + LE32_OUT_FLOAT( vb[0], x1 - ix ); + LE32_OUT_FLOAT( vb[1], y1 - iy ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp1->ui[j]; + LE32_OUT( vb[j], tmp1->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp1->v.x + ix; - *(float *)&vb[1] = tmp1->v.y + iy; + LE32_OUT_FLOAT( vb[0], x1 + ix ); + LE32_OUT_FLOAT( vb[1], y1 + iy ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp1->ui[j]; + LE32_OUT( vb[j], tmp1->ui[j] ); #else @@ -248,47 +271,50 @@ static __inline void r128_draw_line( r128ContextPtr rmesa, } static __inline void r128_draw_point( r128ContextPtr rmesa, - r128VertexPtr tmp, float sz ) + r128VertexPtr tmp, GLfloat sz ) { #if 1 - int vertsize = rmesa->vertsize; + GLuint vertsize = rmesa->vertsize; CARD32 *vb = r128AllocVerticesInline( rmesa, 6 ); int j; + const float x = tmp->v.x + PNT_X_OFFSET; + const float y = tmp->v.y + PNT_Y_OFFSET; - *(float *)&vb[0] = tmp->v.x - sz; - *(float *)&vb[1] = tmp->v.y - sz; + LE32_OUT_FLOAT( vb[0], x - sz ); + LE32_OUT_FLOAT( vb[1], y - sz ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp->ui[j]; + LE32_OUT( vb[j], tmp->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp->v.x + sz; - *(float *)&vb[1] = tmp->v.y - sz; + LE32_OUT_FLOAT( vb[0], x + sz ); + LE32_OUT_FLOAT( vb[1], y - sz ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp->ui[j]; + LE32_OUT( vb[j], tmp->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp->v.x + sz; - *(float *)&vb[1] = tmp->v.y + sz; + LE32_OUT_FLOAT( vb[0], x + sz ); + LE32_OUT_FLOAT( vb[1], y + sz ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp->ui[j]; + LE32_OUT( vb[j], tmp->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp->v.x + sz; - *(float *)&vb[1] = tmp->v.y + sz; + LE32_OUT_FLOAT( vb[0], x + sz ); + LE32_OUT_FLOAT( vb[1], y + sz ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp->ui[j]; + LE32_OUT( vb[j], tmp->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp->v.x - sz; - *(float *)&vb[1] = tmp->v.y + sz; + LE32_OUT_FLOAT( vb[0], x - sz ); + LE32_OUT_FLOAT( vb[1], y + sz ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp->ui[j]; + LE32_OUT( vb[j], tmp->ui[j] ); vb += vertsize; - *(float *)&vb[0] = tmp->v.x - sz; - *(float *)&vb[1] = tmp->v.y - sz; + LE32_OUT_FLOAT( vb[0], x - sz ); + LE32_OUT_FLOAT( vb[1], y - sz ); for (j = 2 ; j < vertsize ; j++) - vb[j] = tmp->ui[j]; + LE32_OUT( vb[j], tmp->ui[j] ); + #else int vertsize = rmesa->vertsize; diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.h b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h index 1a00d9eea..7bb314692 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_vb.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h @@ -30,6 +30,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. * Authors: * Gareth Hughes <gareth@valinux.com> * Kevin E. Martin <martin@valinux.com> + * Michel Dänzer <michdaen@iiic.ethz.ch> * */ @@ -38,13 +39,21 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef GLX_DIRECT_RENDERING -/* FIXME: This is endian-specific */ +#if __BYTE_ORDER == __LITTLE_ENDIAN typedef struct { GLubyte blue; GLubyte green; GLubyte red; GLubyte alpha; } r128_color_t; +#else +typedef struct { + GLubyte alpha; + GLubyte red; + GLubyte green; + GLubyte blue; +} r128_color_t; +#endif /* The vertex structure. The final tu1/tv1 values are only used in * multitexture modes, and the rhw2 value is currently never used. diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c index 4d5c6a5cf..b94669ab6 100644 --- a/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c +++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/radeon_dri.c @@ -871,11 +871,11 @@ static Bool RADEONDRIAgpInit(RADEONInfoPtr info, ScreenPtr pScreen) return TRUE; } +#if 0 /* Initialize the PCIGART state. Request memory for use in PCI space, and initialize the Radeon registers to point to that memory. */ static Bool RADEONDRIPciInit(RADEONInfoPtr info, ScreenPtr pScreen) { - unsigned char *RADEONMMIO = info->MMIO; int ret; int flags; @@ -974,6 +974,7 @@ static Bool RADEONDRIPciInit(RADEONInfoPtr info, ScreenPtr pScreen) return TRUE; } +#endif /* Add a map for the MMIO registers that will be accessed by any DRI-based clients. */ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h index 274751331..085d1cb83 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drmP.h @@ -53,7 +53,7 @@ #include <linux/sched.h> #include <linux/smp_lock.h> /* For (un)lock_kernel */ #include <linux/mm.h> -#ifdef __alpha__ +#if defined(__alpha__) || defined(__powerpc__) #include <asm/pgtable.h> /* For pte_wrprotect */ #endif #include <asm/io.h> @@ -287,12 +287,43 @@ static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, return old; } +#elif defined(__powerpc__) +extern void __cmpxchg_called_with_bad_pointer(void); +static inline unsigned long __cmpxchg(volatile void *ptr, unsigned long old, + unsigned long new, int size) +{ + unsigned long prev; + + switch (size) { + case 4: + __asm__ __volatile__( + "sync;" + "0: lwarx %0,0,%1 ;" + " cmpl 0,%0,%3;" + " bne 1f;" + " stwcx. %2,0,%1;" + " bne- 0b;" + "1: " + "sync;" + : "=&r"(prev) + : "r"(ptr), "r"(new), "r"(old) + : "cr0", "memory"); + return prev; + } + __cmpxchg_called_with_bad_pointer(); + return old; +} + +#endif /* i386, powerpc & alpha */ + +#ifndef __alpha__ #define cmpxchg(ptr,o,n) \ ((__typeof__(*(ptr)))__cmpxchg((ptr),(unsigned long)(o), \ (unsigned long)(n),sizeof(*(ptr)))) -#endif /* i386 & alpha */ #endif +#endif /* !__HAVE_ARCH_CMPXCHG */ + /* Macros to make printk easier */ #define DRM_ERROR(fmt, arg...) \ printk(KERN_ERR "[" DRM_NAME ":" __FUNCTION__ "] *ERROR* " fmt , ##arg) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_vm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_vm.h index 26906aee2..771c11bd2 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_vm.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm_vm.h @@ -424,7 +424,10 @@ int DRM(mmap)(struct file *filp, struct vm_area_struct *vma) } #elif defined(__ia64__) if (map->type != _DRM_AGP) - vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot); + vma->vm_page_prot = + pgprot_writecombine(vma->vm_page_prot); +#elif defined(__powerpc__) + pgprot_val(vma->vm_page_prot) |= _PAGE_NO_CACHE | _PAGE_GUARDED; #endif vma->vm_flags |= VM_IO; /* not in core dump */ } diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_cce.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_cce.c index da44a496a..1ced05fe9 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_cce.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_cce.c @@ -210,7 +210,7 @@ int r128_do_cce_idle( drm_r128_private_t *dev_priv ) int i; for ( i = 0 ; i < dev_priv->usec_timeout ; i++ ) { - if ( *dev_priv->ring.head == dev_priv->ring.tail ) { + if ( GET_RING_HEAD( &dev_priv->ring ) == dev_priv->ring.tail ) { int pm4stat = R128_READ( R128_PM4_STAT ); if ( ( (pm4stat & R128_PM4_FIFOCNT_MASK) >= dev_priv->cce_fifo_size ) && @@ -251,7 +251,7 @@ static void r128_do_cce_reset( drm_r128_private_t *dev_priv ) { R128_WRITE( R128_PM4_BUFFER_DL_WPTR, 0 ); R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 ); - *dev_priv->ring.head = 0; + SET_RING_HEAD( &dev_priv->ring, 0 ); dev_priv->ring.tail = 0; } @@ -332,7 +332,7 @@ static void r128_cce_init_ring_buffer( drm_device_t *dev ) R128_WRITE( R128_PM4_BUFFER_DL_RPTR, 0 ); /* DL_RPTR_ADDR is a physical address in AGP space. */ - *dev_priv->ring.head = 0; + SET_RING_HEAD( &dev_priv->ring, 0 ); if ( !dev_priv->is_pci ) { R128_WRITE( R128_PM4_BUFFER_DL_RPTR_ADDR, diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c index 7e736541c..584cb29c3 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c @@ -39,11 +39,11 @@ #define DRIVER_NAME "r128" #define DRIVER_DESC "ATI Rage 128" -#define DRIVER_DATE "20010308" +#define DRIVER_DATE "20010405" #define DRIVER_MAJOR 2 #define DRIVER_MINOR 1 -#define DRIVER_PATCHLEVEL 5 +#define DRIVER_PATCHLEVEL 6 #define DRIVER_IOCTLS \ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { r128_cce_buffers, 1, 0 }, \ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h index bf682998b..fbc692298 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h @@ -28,11 +28,15 @@ * Rickard E. (Rik) Faith <faith@valinux.com> * Kevin E. Martin <martin@valinux.com> * Gareth Hughes <gareth@valinux.com> + * Michel Dänzer <daenzerm@student.ethz.ch> */ #ifndef __R128_DRV_H__ #define __R128_DRV_H__ +#define GET_RING_HEAD( ring ) le32_to_cpu( *(ring)->head ) +#define SET_RING_HEAD( ring, val ) *(ring)->head = cpu_to_le32( val ) + typedef struct drm_r128_freelist { unsigned int age; drm_buf_t *buf; @@ -136,7 +140,7 @@ extern int r128_wait_ring( drm_r128_private_t *dev_priv, int n ); static inline void r128_update_ring_snapshot( drm_r128_ring_buffer_t *ring ) { - ring->space = (*(volatile int *)ring->head - ring->tail) * sizeof(u32); + ring->space = (GET_RING_HEAD( ring ) - ring->tail) * sizeof(u32); if ( ring->space <= 0 ) ring->space += ring->size; } @@ -368,7 +372,7 @@ extern int r128_cce_indirect( struct inode *inode, struct file *filp, #define R128_LAST_FRAME_REG R128_GUI_SCRATCH_REG0 #define R128_LAST_DISPATCH_REG R128_GUI_SCRATCH_REG1 -#define R128_MAX_VB_AGE 0xffffffff +#define R128_MAX_VB_AGE 0x7fffffff #define R128_MAX_VB_VERTS (0xffff) #define R128_RING_HIGH_MARK 128 @@ -389,8 +393,8 @@ static inline u32 _R128_READ(u32 *addr) { #define R128_WRITE(reg,val) \ do { wmb(); R128_DEREF(reg) = val; } while (0) #else -#define R128_READ(reg) R128_DEREF( reg ) -#define R128_WRITE(reg,val) do { R128_DEREF( reg ) = val; } while (0) +#define R128_READ(reg) le32_to_cpu( R128_DEREF( reg ) ) +#define R128_WRITE(reg,val) do { R128_DEREF( reg ) = cpu_to_le32( val ); } while (0) #endif #define R128_DEREF8(reg) *(volatile u8 *)R128_ADDR( reg ) @@ -525,7 +529,7 @@ do { \ DRM_INFO( " OUT_RING( 0x%08x ) at 0x%x\n", \ (unsigned int)(x), write ); \ } \ - ring[write++] = (x); \ + ring[write++] = cpu_to_le32( x ); \ write &= tail_mask; \ } while (0) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_state.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_state.c index 1006a77c1..7eafd72d6 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_state.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_state.c @@ -660,7 +660,7 @@ static void r128_cce_dispatch_indirect( drm_device_t *dev, u32 *data = (u32 *) ((char *)dev_priv->buffers->handle + buf->offset + start); - data[dwords++] = R128_CCE_PACKET2; + data[dwords++] = cpu_to_le32( R128_CCE_PACKET2 ); } buf_priv->dispatched = 1; @@ -727,16 +727,21 @@ static void r128_cce_dispatch_indices( drm_device_t *dev, data = (u32 *)((char *)dev_priv->buffers->handle + buf->offset + start); - data[0] = CCE_PACKET3( R128_3D_RNDR_GEN_INDX_PRIM, dwords-2 ); + data[0] = cpu_to_le32( CCE_PACKET3( R128_3D_RNDR_GEN_INDX_PRIM, + dwords-2 ) ); - data[1] = offset; - data[2] = R128_MAX_VB_VERTS; - data[3] = format; - data[4] = (prim | R128_CCE_VC_CNTL_PRIM_WALK_IND | - (count << 16)); + data[1] = cpu_to_le32( offset ); + data[2] = cpu_to_le32( R128_MAX_VB_VERTS ); + data[3] = cpu_to_le32( format ); + data[4] = cpu_to_le32( (prim | R128_CCE_VC_CNTL_PRIM_WALK_IND | + (count << 16)) ); if ( count & 0x1 ) { +#ifdef __LITTLE_ENDIAN data[dwords-1] &= 0x0000ffff; +#else + data[dwords-1] &= 0xffff0000; +#endif } do { @@ -842,23 +847,23 @@ static int r128_cce_dispatch_blit( drm_device_t *dev, data = (u32 *)((char *)dev_priv->buffers->handle + buf->offset); - data[0] = CCE_PACKET3( R128_CNTL_HOSTDATA_BLT, dwords + 6 ); - data[1] = (R128_GMC_DST_PITCH_OFFSET_CNTL | - R128_GMC_BRUSH_NONE | - (blit->format << 8) | - R128_GMC_SRC_DATATYPE_COLOR | - R128_ROP3_S | - R128_DP_SRC_SOURCE_HOST_DATA | - R128_GMC_CLR_CMP_CNTL_DIS | - R128_GMC_AUX_CLIP_DIS | - R128_GMC_WR_MSK_DIS); - - data[2] = (blit->pitch << 21) | (blit->offset >> 5); - data[3] = 0xffffffff; - data[4] = 0xffffffff; - data[5] = (blit->y << 16) | blit->x; - data[6] = (blit->height << 16) | blit->width; - data[7] = dwords; + data[0] = cpu_to_le32( CCE_PACKET3( R128_CNTL_HOSTDATA_BLT, dwords + 6 ) ); + data[1] = cpu_to_le32( (R128_GMC_DST_PITCH_OFFSET_CNTL | + R128_GMC_BRUSH_NONE | + (blit->format << 8) | + R128_GMC_SRC_DATATYPE_COLOR | + R128_ROP3_S | + R128_DP_SRC_SOURCE_HOST_DATA | + R128_GMC_CLR_CMP_CNTL_DIS | + R128_GMC_AUX_CLIP_DIS | + R128_GMC_WR_MSK_DIS) ); + + data[2] = cpu_to_le32( (blit->pitch << 21) | (blit->offset >> 5) ); + data[3] = cpu_to_le32( 0xffffffff ); + data[4] = cpu_to_le32( 0xffffffff ); + data[5] = cpu_to_le32( (blit->y << 16) | blit->x ); + data[6] = cpu_to_le32( (blit->height << 16) | blit->width ); + data[7] = cpu_to_le32( dwords ); buf->used = (dwords + 8) * sizeof(u32); diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/radeon_drv.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/radeon_drv.c index 3791c5ecb..59497acae 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/radeon_drv.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/radeon_drv.c @@ -37,11 +37,11 @@ #define DRIVER_NAME "radeon" #define DRIVER_DESC "ATI Radeon" -#define DRIVER_DATE "20010308" +#define DRIVER_DATE "20010405" #define DRIVER_MAJOR 1 #define DRIVER_MINOR 0 -#define DRIVER_PATCHLEVEL 1 +#define DRIVER_PATCHLEVEL 2 #define DRIVER_IOCTLS \ [DRM_IOCTL_NR(DRM_IOCTL_DMA)] = { radeon_cp_buffers, 1, 0 }, \ diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h index e3702c2cf..7a07c7e0f 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drm.h @@ -315,6 +315,25 @@ do { register unsigned int __old __asm("o0"); \ } while (0) #endif + +#elif defined(__powerpc__) + +#define DRM_CAS(lock,old,new,__ret) \ + do { \ + __asm__ __volatile__( \ + "sync;" \ + "0: lwarx %0,0,%1;" \ + " xor. %0,%3,%0;" \ + " bne 1f;" \ + " stwcx. %2,0,%1;" \ + " bne- 0b;" \ + "1: " \ + "sync;" \ + : "=&r"(__ret) \ + : "r"(lock), "r"(new), "r"(old) \ + : "cr0", "memory"); \ + } while (0) + #endif /* architecture */ #endif /* __GNUC__ >= 2 */ |