summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgareth <gareth>2000-12-01 15:39:31 +0000
committergareth <gareth>2000-12-01 15:39:31 +0000
commitd03307dd9f98036c40abf2f98dac3fde22ef2e89 (patch)
treed329c450e9f46571455b4d01f17f87dc04c720ac
parent49e06dbed59638b5ef4715f032f9aeda47124fa0 (diff)
- Fixed polygon stipple. Was still using SubmitPackets...ati-4-1-1-20001201-freeze
- Implemented HW-assisted depth span functions. All access to the depth buffer is done via the engine, so we don't have to worry about the differences between linear and tiled memory. - Implemented significantly more 3D-friendly static partitioning of offscreen memory. 2D still gets enough pixmap cache to be performant. For example, 800x600@16bpp texture memory goes from ~3mb to 11.5mb on a 16mb card.
-rw-r--r--xc/lib/GL/mesa/src/drv/common/depthtmp.h113
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.c4
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_context.h2
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_dd.c2
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c184
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h15
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_screen.c38
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_screen.h1
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_span.c383
-rw-r--r--xc/lib/GL/mesa/src/drv/r128/r128_state.c9
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h13
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c57
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h16
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c356
-rw-r--r--xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h2
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_cce.c9
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h24
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.c8
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drv.h19
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_state.c500
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c102
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h4
-rw-r--r--xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h24
24 files changed, 1441 insertions, 448 deletions
diff --git a/xc/lib/GL/mesa/src/drv/common/depthtmp.h b/xc/lib/GL/mesa/src/drv/common/depthtmp.h
index 3aa307904..2098396e4 100644
--- a/xc/lib/GL/mesa/src/drv/common/depthtmp.h
+++ b/xc/lib/GL/mesa/src/drv/common/depthtmp.h
@@ -2,11 +2,17 @@
#define DBG 0
#endif
+#ifndef HAVE_HW_DEPTH_SPANS
+#define HAVE_HW_DEPTH_SPANS 0
+#endif
+#ifndef HAVE_HW_DEPTH_PIXELS
+#define HAVE_HW_DEPTH_PIXELS 0
+#endif
static void TAG(WriteDepthSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
- const GLdepth *depth,
+ const GLdepth *depth,
const GLubyte mask[] )
{
HW_LOCK()
@@ -15,39 +21,45 @@ static void TAG(WriteDepthSpan)( GLcontext *ctx,
GLint n1;
LOCAL_DEPTH_VARS;
- y = Y_FLIP(y);
+ y = Y_FLIP( y );
+
+#if HAVE_HW_DEPTH_SPANS
+ (void) x1; (void) n1;
- HW_CLIPLOOP()
+ if ( DBG ) fprintf( stderr, "WriteDepthSpan 0..%d (x1 %d)\n",
+ (int)n, (int)x );
+
+ WRITE_DEPTH_SPAN();
+#else
+ HW_CLIPLOOP()
{
GLint i = 0;
- CLIPSPAN(x,y,n,x1,n1,i);
+ CLIPSPAN( x, y, n, x1, n1, i );
- if (DBG) fprintf(stderr, "WriteDepthSpan %d..%d (x1 %d)\n",
- (int)i, (int)n1, (int)x1);
+ if ( DBG ) fprintf( stderr, "WriteDepthSpan %d..%d (x1 %d)\n",
+ (int)i, (int)n1, (int)x1 );
- if (mask)
- {
- for (;i<n1;i++,x1++)
- if (mask[i])
- WRITE_DEPTH( x1, y, depth[i] );
- }
- else
- {
- for (;i<n1;i++,x1++)
+ if ( mask ) {
+ for ( ; i < n1 ; i++, x1++ ) {
+ if ( mask[i] ) WRITE_DEPTH( x1, y, depth[i] );
+ }
+ } else {
+ for ( ; i < n1 ; i++, x1++ ) {
WRITE_DEPTH( x1, y, depth[i] );
+ }
}
}
HW_ENDCLIPLOOP();
+#endif
}
HW_UNLOCK();
}
-
static void TAG(WriteDepthPixels)( GLcontext *ctx,
- GLuint n,
- const GLint x[],
+ GLuint n,
+ const GLint x[],
const GLint y[],
- const GLdepth depth[],
+ const GLdepth depth[],
const GLubyte mask[] )
{
HW_LOCK()
@@ -55,55 +67,64 @@ static void TAG(WriteDepthPixels)( GLcontext *ctx,
GLint i;
LOCAL_DEPTH_VARS;
- if (DBG) fprintf(stderr, "WriteDepthPixels\n");
+ if ( DBG ) fprintf( stderr, "WriteDepthPixels\n" );
+
+#if HAVE_HW_DEPTH_PIXELS
+ (void) i;
+ WRITE_DEPTH_PIXELS();
+#else
HW_CLIPLOOP()
{
- for (i=0;i<n;i++)
- {
- if (mask[i]) {
- const int fy = Y_FLIP(y[i]);
- if (CLIPPIXEL(x[i],fy))
+ for ( i = 0 ; i < n ; i++ ) {
+ if ( mask[i] ) {
+ const int fy = Y_FLIP( y[i] );
+ if ( CLIPPIXEL( x[i], fy ) )
WRITE_DEPTH( x[i], fy, depth[i] );
}
}
}
HW_ENDCLIPLOOP();
+#endif
}
HW_UNLOCK();
}
-
-
/* Read depth spans and pixels
*/
static void TAG(ReadDepthSpan)( GLcontext *ctx,
GLuint n, GLint x, GLint y,
- GLdepth depth[])
+ GLdepth depth[] )
{
HW_LOCK()
{
- GLint x1,n1;
+ GLint x1, n1;
LOCAL_DEPTH_VARS;
- y = Y_FLIP(y);
+ y = Y_FLIP( y );
- if (DBG) fprintf(stderr, "ReadDepthSpan\n");
+ if ( DBG ) fprintf( stderr, "ReadDepthSpan\n" );
- HW_CLIPLOOP()
+#if HAVE_HW_DEPTH_SPANS
+ (void) x1; (void) n1;
+
+ READ_DEPTH_SPAN();
+#else
+ HW_CLIPLOOP()
{
GLint i = 0;
- CLIPSPAN(x,y,n,x1,n1,i);
- for (;i<n1;i++)
+ CLIPSPAN( x, y, n, x1, n1, i );
+ for ( ; i < n1 ; i++ )
READ_DEPTH( depth[i], (x1+i), y );
}
HW_ENDCLIPLOOP();
+#endif
}
HW_UNLOCK();
}
-static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
+static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
const GLint x[], const GLint y[],
GLdepth depth[] )
{
@@ -112,22 +133,34 @@ static void TAG(ReadDepthPixels)( GLcontext *ctx, GLuint n,
GLint i;
LOCAL_DEPTH_VARS;
- if (DBG) fprintf(stderr, "ReadDepthPixels\n");
-
+ if ( DBG ) fprintf( stderr, "ReadDepthPixels\n" );
+
+#if HAVE_HW_DEPTH_PIXELS
+ (void) i;
+
+ READ_DEPTH_PIXELS();
+#else
HW_CLIPLOOP()
{
- for (i=0;i<n;i++) {
+ for ( i = 0 ; i < n ;i++ ) {
int fy = Y_FLIP( y[i] );
- if (CLIPPIXEL( x[i], fy ))
+ if ( CLIPPIXEL( x[i], fy ) )
READ_DEPTH( depth[i], x[i], fy );
}
}
HW_ENDCLIPLOOP();
+#endif
}
HW_UNLOCK();
}
-
+#if HAVE_HW_DEPTH_SPANS
+#undef WRITE_DEPTH_SPAN;
+#undef WRITE_DEPTH_PIXELS;
+#undef READ_DEPTH_SPAN;
+#undef READ_DEPTH_PIXELS;
+#else
#undef WRITE_DEPTH
#undef READ_DEPTH
+#endif
#undef TAG
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_context.c b/xc/lib/GL/mesa/src/drv/r128/r128_context.c
index aa291223e..c1dc0083c 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_context.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.c
@@ -103,9 +103,11 @@ GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual,
r128ctx->retained_buf = NULL;
r128ctx->vert_heap = r128ctx->r128Screen->buffers->list->address;
+#if 0
r128ctx->CCEbuf= (CARD32 *)MALLOC(sizeof(*r128ctx->CCEbuf) *
r128scrn->ringEntries);
r128ctx->CCEcount = 0;
+#endif
if ((v = getenv("LIBGL_CCE_TIMEOUT")))
r128ctx->CCEtimeout = strtoul(v, NULL, 10);
@@ -187,7 +189,9 @@ void r128DestroyContext(r128ContextPtr r128ctx)
r128TexObjPtr t, next_t;
int i;
+#if 0
FREE( r128ctx->CCEbuf );
+#endif
for (i = 0; i < r128ctx->r128Screen->NRTexHeaps; i++) {
foreach_s (t, next_t, &r128ctx->TexObjList[i])
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 736295349..640768c27 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_context.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.h
@@ -186,8 +186,10 @@ struct r128_context {
/* CCE command packets
*/
+#if 0
CARD32 *CCEbuf; /* buffer to submit to CCE */
GLuint CCEcount; /* number of dwords in CCEbuf */
+#endif
GLint CCEtimeout; /* number of times to loop
before exiting */
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 dd7f35120..4d2ba6296 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 "20001129"
+#define R128_DATE "20001201"
/* Return the current color buffer size */
static void r128DDGetBufferSize( GLcontext *ctx,
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 46d048c7a..44952b22d 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.c
@@ -528,6 +528,190 @@ static GLbitfield r128DDClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
}
+/* ================================================================
+ * Depth spans, pixels
+ */
+
+void r128WriteDepthSpanLocked( r128ContextPtr r128ctx,
+ GLuint n, GLint x, GLint y,
+ const GLdepth depth[],
+ const GLubyte mask[] )
+{
+ XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+ int nbox = r128ctx->numClipRects;
+ int fd = r128ctx->driScreen->fd;
+ int i;
+
+ if ( !nbox || !n ) {
+ return;
+ }
+ if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+ r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
+
+ if ( !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+ {
+ if ( nbox < 3 ) {
+ r128ctx->sarea->nbox = 0;
+ } else {
+ r128ctx->sarea->nbox = nbox;
+ }
+
+ drmR128WriteDepthSpan( fd, n, x, y, depth, mask );
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+ XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+
+ r128ctx->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++) {
+ *b++ = pbox[i];
+ }
+
+ r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+ drmR128WriteDepthSpan( fd, n, x, y, depth, mask );
+ }
+ }
+
+ r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128WriteDepthPixelsLocked( r128ContextPtr r128ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth depth[],
+ const GLubyte mask[] )
+{
+ XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+ int nbox = r128ctx->numClipRects;
+ int fd = r128ctx->driScreen->fd;
+ int i;
+
+ if ( !nbox || !n ) {
+ return;
+ }
+ if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+ r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
+
+ if ( !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+ {
+ if ( nbox < 3 ) {
+ r128ctx->sarea->nbox = 0;
+ } else {
+ r128ctx->sarea->nbox = nbox;
+ }
+
+ drmR128WriteDepthPixels( fd, n, x, y, depth, mask );
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+ XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+
+ r128ctx->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++) {
+ *b++ = pbox[i];
+ }
+
+ r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+ drmR128WriteDepthPixels( fd, n, x, y, depth, mask );
+ }
+ }
+
+ r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128ReadDepthSpanLocked( r128ContextPtr r128ctx,
+ GLuint n, GLint x, GLint y )
+{
+ XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+ int nbox = r128ctx->numClipRects;
+ int fd = r128ctx->driScreen->fd;
+ int i;
+
+ if ( !nbox || !n ) {
+ return;
+ }
+ if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+ r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
+
+ if ( !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+ {
+ if ( nbox < 3 ) {
+ r128ctx->sarea->nbox = 0;
+ } else {
+ r128ctx->sarea->nbox = nbox;
+ }
+
+ drmR128ReadDepthSpan( fd, n, x, y );
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+ XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+
+ r128ctx->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++) {
+ *b++ = pbox[i];
+ }
+
+ r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+ drmR128ReadDepthSpan( fd, n, x, y );
+ }
+ }
+
+ r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
+void r128ReadDepthPixelsLocked( r128ContextPtr r128ctx, GLuint n,
+ const GLint x[], const GLint y[] )
+{
+ XF86DRIClipRectPtr pbox = r128ctx->pClipRects;
+ int nbox = r128ctx->numClipRects;
+ int fd = r128ctx->driScreen->fd;
+ int i;
+
+ if ( !nbox || !n ) {
+ return;
+ }
+ if ( nbox >= R128_NR_SAREA_CLIPRECTS ) {
+ r128ctx->dirty |= R128_UPLOAD_CLIPRECTS;
+ }
+
+ if ( !(r128ctx->dirty & R128_UPLOAD_CLIPRECTS) )
+ {
+ if ( nbox < 3 ) {
+ r128ctx->sarea->nbox = 0;
+ } else {
+ r128ctx->sarea->nbox = nbox;
+ }
+
+ drmR128ReadDepthPixels( fd, n, x, y );
+ }
+ else
+ {
+ for (i = 0 ; i < nbox ; ) {
+ int nr = MIN2( i + R128_NR_SAREA_CLIPRECTS, nbox );
+ XF86DRIClipRectPtr b = r128ctx->sarea->boxes;
+
+ r128ctx->sarea->nbox = nr - i;
+ for ( ; i < nr ; i++) {
+ *b++ = pbox[i];
+ }
+
+ r128ctx->sarea->dirty |= R128_UPLOAD_CLIPRECTS;
+ drmR128ReadDepthPixels( fd, n, x, y );
+ }
+ }
+
+ r128ctx->dirty &= ~R128_UPLOAD_CLIPRECTS;
+}
+
/* ================================================================
* Deprecated function...
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h b/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h
index 587b63163..333e67541 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_ioctl.h
@@ -141,6 +141,21 @@ extern void r128FireBlitLocked( r128ContextPtr r128ctx, drmBufPtr buffer,
GLint offset, GLint pitch, GLint format,
GLint x, GLint y, GLint width, GLint height );
+
+extern void r128WriteDepthSpanLocked( r128ContextPtr r128ctx,
+ GLuint n, GLint x, GLint y,
+ const GLdepth depth[],
+ const GLubyte mask[] );
+extern void r128WriteDepthPixelsLocked( r128ContextPtr r128ctx, GLuint n,
+ const GLint x[], const GLint y[],
+ const GLdepth depth[],
+ const GLubyte mask[] );
+extern void r128ReadDepthSpanLocked( r128ContextPtr r128ctx,
+ GLuint n, GLint x, GLint y );
+extern void r128ReadDepthPixelsLocked( r128ContextPtr r128ctx, GLuint n,
+ const GLint x[], const GLint y[] );
+
+
extern void r128SwapBuffers( r128ContextPtr r128ctx );
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_screen.c b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
index d247ede43..eda2d7aa2 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c
@@ -171,33 +171,17 @@ r128ScreenPtr r128CreateScreen(__DRIscreenPrivate *sPriv)
r128Screen->fbStride = sPriv->fbStride;
r128Screen->fbSize = sPriv->fbSize;
- r128Screen->frontX = r128DRIPriv->fbX;
- r128Screen->frontY = r128DRIPriv->fbY;
- r128Screen->frontOffset = (r128DRIPriv->fbY *
- r128Screen->fbStride +
- r128DRIPriv->fbX * cpp);
- r128Screen->frontPitch = r128Screen->fbStride / cpp;
-
- r128Screen->backX = r128DRIPriv->backX;
- r128Screen->backY = r128DRIPriv->backY;
- r128Screen->backOffset = (r128DRIPriv->backY *
- r128Screen->fbStride +
- r128Screen->backX * cpp);
- r128Screen->backPitch = r128Screen->fbStride / cpp;
-
- r128Screen->depthX = r128DRIPriv->depthX;
- r128Screen->depthY = r128DRIPriv->depthY;
- r128Screen->depthOffset = (r128DRIPriv->depthY *
- r128Screen->fbStride +
- r128Screen->depthX * cpp);
- r128Screen->depthPitch = r128Screen->fbStride / cpp;
-
- r128Screen->texOffset[R128_LOCAL_TEX_HEAP] = (r128DRIPriv->textureY *
- r128Screen->fbStride +
- r128DRIPriv->textureX *
- (r128Screen->bpp/8));
- r128Screen->texSize[R128_LOCAL_TEX_HEAP] = r128DRIPriv->textureSize;
- r128Screen->log2TexGran[R128_LOCAL_TEX_HEAP] = r128DRIPriv->log2TexGran;
+ r128Screen->frontOffset = r128DRIPriv->frontOffset;
+ r128Screen->frontPitch = r128DRIPriv->frontPitch;
+ r128Screen->backOffset = r128DRIPriv->backOffset;
+ r128Screen->backPitch = r128DRIPriv->backPitch;
+ r128Screen->depthOffset = r128DRIPriv->depthOffset;
+ r128Screen->depthPitch = r128DRIPriv->depthPitch;
+ r128Screen->spanOffset = r128DRIPriv->spanOffset;
+
+ r128Screen->texOffset[R128_LOCAL_TEX_HEAP] = r128DRIPriv->textureOffset;
+ r128Screen->texSize[R128_LOCAL_TEX_HEAP] = r128DRIPriv->textureSize;
+ r128Screen->log2TexGran[R128_LOCAL_TEX_HEAP] = r128DRIPriv->log2TexGran;
if (r128Screen->IsPCI) {
r128Screen->texOffset[R128_AGP_TEX_HEAP] = 0;
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_screen.h b/xc/lib/GL/mesa/src/drv/r128/r128_screen.h
index 0ea5a8002..5326b94e7 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_screen.h
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.h
@@ -81,6 +81,7 @@ typedef struct {
unsigned int backOffset, backPitch;
unsigned int depthX, depthY; /* Start of shared depth buffer */
unsigned int depthOffset, depthPitch;
+ unsigned int spanOffset;
int chipset;
int IsPCI; /* Current card is a PCI card */
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_span.c b/xc/lib/GL/mesa/src/drv/r128/r128_span.c
index 69ea7c09d..9483dafe7 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_span.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_span.c
@@ -39,10 +39,15 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#include "r128_state.h"
#include "r128_span.h"
+#include "pb.h"
+
#define DBG 0
+#define HAVE_HW_DEPTH_SPANS 1
+#define HAVE_HW_DEPTH_PIXELS 1
+
#define LOCAL_VARS \
- r128ContextPtr r128ctx = R128_CONTEXT( ctx ); \
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx); \
r128ScreenPtr r128scrn = r128ctx->r128Screen; \
__DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \
GLuint pitch = r128scrn->fbStride; \
@@ -60,18 +65,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define LOCAL_DEPTH_VARS \
r128ContextPtr r128ctx = R128_CONTEXT(ctx); \
- r128ScreenPtr r128scrn = r128ctx->r128Screen; \
__DRIdrawablePrivate *dPriv = r128ctx->driDrawable; \
- GLuint pitch = r128scrn->fbStride; \
GLuint height = dPriv->h; \
- char *buf = (char *)(r128scrn->fb + \
- r128scrn->depthOffset + \
- (dPriv->x * r128scrn->bpp/8) + \
- (dPriv->y * pitch)); \
- (void) buf
+ (void) height
#define INIT_MONO_PIXEL( p ) \
- p = R128_CONTEXT(ctx)->Color
+ p = r128ctx->Color
#define CLIPPIXEL( _x, _y ) \
((_x >= minx) && (_x < maxx) && (_y >= miny) && (_y < maxy))
@@ -91,7 +90,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE.
#define HW_LOCK() \
- r128ContextPtr r128ctx = R128_CONTEXT( ctx ); \
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx); \
FLUSH_BATCH( r128ctx ); \
LOCK_HARDWARE( r128ctx ); \
r128WaitForIdleLocked( r128ctx );
@@ -210,130 +209,292 @@ do { \
-/* 16 bit depthbuffer functions */
-#define WRITE_DEPTH( _x, _y, d ) \
- *(GLushort *)(buf + _x*2 + _y*pitch) = d;
+/* 16-bit depth buffer functions */
-#define READ_DEPTH( d, _x, _y ) \
- d = *(GLushort *)(buf + _x*2 + _y*pitch)
+#define WRITE_DEPTH_SPAN() \
+ r128WriteDepthSpanLocked( r128ctx, n, x, y, depth, mask );
+
+#define WRITE_DEPTH_PIXELS() \
+do { \
+ GLint fy[PB_SIZE]; \
+ for ( i = 0 ; i < n ; i++ ) { \
+ fy[i] = Y_FLIP( y[i] ); \
+ } \
+ r128WriteDepthPixelsLocked( r128ctx, n, x, fy, depth, mask ); \
+} while (0)
+
+#define READ_DEPTH_SPAN() \
+do { \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ GLushort *buf = (GLushort *)((GLubyte *)r128scrn->fb + \
+ r128scrn->spanOffset); \
+ GLint i; \
+ \
+ r128ReadDepthSpanLocked( r128ctx, n, x, y ); \
+ r128WaitForIdleLocked( r128ctx ); \
+ \
+ for ( i = 0 ; i < n ; i++ ) { \
+ depth[i] = buf[i]; \
+ } \
+} while (0)
+
+#define READ_DEPTH_PIXELS() \
+do { \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ GLushort *buf = (GLushort *)((GLubyte *)r128scrn->fb + \
+ r128scrn->spanOffset); \
+ GLint i, remaining = n; \
+ \
+ while ( remaining > 0 ) { \
+ GLint fy[PB_SIZE]; \
+ GLint count; \
+ \
+ if ( remaining <= 128 ) { \
+ count = remaining; \
+ } else { \
+ count = 128; \
+ } \
+ for ( i = 0 ; i < count ; i++ ) { \
+ fy[i] = Y_FLIP( y[i] ); \
+ } \
+ \
+ r128ReadDepthPixelsLocked( r128ctx, count, x, fy ); \
+ r128WaitForIdleLocked( r128ctx ); \
+ \
+ for ( i = 0 ; i < count ; i++ ) { \
+ depth[i] = buf[i]; \
+ } \
+ depth += count; \
+ x += count; \
+ y += count; \
+ remaining -= count; \
+ } \
+} while (0)
#define TAG(x) r128##x##_16
#include "depthtmp.h"
-/* 24 bit depth, 8 bit stencil depthbuffer functions */
-#define WRITE_DEPTH( _x, _y, d ) \
+/* 24-bit depth, 8-bit stencil buffer functions */
+
+#define WRITE_DEPTH_SPAN() \
+ r128WriteDepthSpanLocked( r128ctx, n, x, y, depth, mask );
+
+#define WRITE_DEPTH_PIXELS() \
do { \
- GLuint _d = *(GLuint *)(buf + _x*4 + _y*pitch); \
- _d &= 0xff000000; \
- _d |= (d & 0x00ffffff); \
- *(GLuint *)(buf + _x*4 + _y*pitch) = _d; \
+ GLint fy[PB_SIZE]; \
+ for ( i = 0 ; i < n ; i++ ) { \
+ fy[i] = Y_FLIP( y[i] ); \
+ } \
+ r128WriteDepthPixelsLocked( r128ctx, n, x, fy, depth, mask ); \
+} while (0)
+
+#define READ_DEPTH_SPAN() \
+do { \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ GLuint *buf = (GLuint *)((GLubyte *)r128scrn->fb + \
+ r128scrn->spanOffset); \
+ GLint i; \
+ \
+ r128ReadDepthSpanLocked( r128ctx, n, x, y ); \
+ r128WaitForIdleLocked( r128ctx ); \
+ \
+ for ( i = 0 ; i < n ; i++ ) { \
+ depth[i] = buf[i] & 0x00ffffff; \
+ } \
} while (0)
-#define READ_DEPTH( d, _x, _y ) \
- d = *(GLuint *)(buf + _x*4 + _y*pitch) & 0x00ffffff;
+
+#define READ_DEPTH_PIXELS() \
+do { \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ GLuint *buf = (GLuint *)((GLubyte *)r128scrn->fb + \
+ r128scrn->spanOffset); \
+ GLint i, remaining = n; \
+ \
+ while ( remaining > 0 ) { \
+ GLint fy[PB_SIZE]; \
+ GLint count; \
+ \
+ if ( remaining <= 128 ) { \
+ count = remaining; \
+ } else { \
+ count = 128; \
+ } \
+ for ( i = 0 ; i < count ; i++ ) { \
+ fy[i] = Y_FLIP( y[i] ); \
+ } \
+ \
+ r128ReadDepthPixelsLocked( r128ctx, count, x, fy ); \
+ r128WaitForIdleLocked( r128ctx ); \
+ \
+ for ( i = 0 ; i < count ; i++ ) { \
+ depth[i] = buf[i] & 0x00ffffff; \
+ } \
+ depth += count; \
+ x += count; \
+ y += count; \
+ remaining -= count; \
+ } \
+} while (0)
#define TAG(x) r128##x##_24_8
#include "depthtmp.h"
-/* 32 bit depthbuffer functions */
-#define WRITE_DEPTH( _x, _y, d ) \
- *(GLuint *)(buf + _x*4 + _y*pitch) = d
+/* 32-bit depth buffer functions */
+
+#define WRITE_DEPTH_SPAN() \
+ r128WriteDepthSpanLocked( r128ctx, n, x, y, depth, mask );
+
+#define WRITE_DEPTH_PIXELS() \
+do { \
+ GLint fy[PB_SIZE]; \
+ for ( i = 0 ; i < n ; i++ ) { \
+ fy[i] = Y_FLIP( y[i] ); \
+ } \
+ r128WriteDepthPixelsLocked( r128ctx, n, x, fy, depth, mask ); \
+} while (0)
+
+#define READ_DEPTH_SPAN() \
+do { \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ GLuint *buf = (GLuint *)((GLubyte *)r128scrn->fb + \
+ r128scrn->spanOffset); \
+ GLint i; \
+ \
+ r128ReadDepthSpanLocked( r128ctx, n, x, y ); \
+ r128WaitForIdleLocked( r128ctx ); \
+ \
+ for ( i = 0 ; i < n ; i++ ) { \
+ depth[i] = buf[i]; \
+ } \
+} while (0)
-#define READ_DEPTH( d, _x, _y ) \
- d = *(GLuint *)(buf + _x*4 + _y*pitch)
+#define READ_DEPTH_PIXELS() \
+do { \
+ r128ScreenPtr r128scrn = r128ctx->r128Screen; \
+ GLuint *buf = (GLuint *)((GLubyte *)r128scrn->fb + \
+ r128scrn->spanOffset); \
+ GLint i, remaining = n; \
+ \
+ while ( remaining > 0 ) { \
+ GLint fy[PB_SIZE]; \
+ GLint count; \
+ \
+ if ( remaining <= 128 ) { \
+ count = remaining; \
+ } else { \
+ count = 128; \
+ } \
+ for ( i = 0 ; i < count ; i++ ) { \
+ fy[i] = Y_FLIP( y[i] ); \
+ } \
+ \
+ r128ReadDepthPixelsLocked( r128ctx, count, x, fy ); \
+ r128WaitForIdleLocked( r128ctx ); \
+ \
+ for ( i = 0 ; i < count ; i++ ) { \
+ depth[i] = buf[i]; \
+ } \
+ depth += count; \
+ x += count; \
+ y += count; \
+ remaining -= count; \
+ } \
+} while (0)
#define TAG(x) r128##x##_32
#include "depthtmp.h"
+
void r128DDInitSpanFuncs( GLcontext *ctx )
{
- r128ContextPtr r128ctx = R128_CONTEXT( ctx );
-
- switch ( r128ctx->BufferSize ) {
- case 8: /* Color Index mode not supported */
- break;
-
- case 15:
- ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_ARGB1555;
- ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_ARGB1555;
- ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB1555;
- ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_ARGB1555;
- ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB1555;
- ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_ARGB1555;
- ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_ARGB1555;
- break;
-
- case 16:
- ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_RGB565;
- ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_RGB565;
- ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB565;
- ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_RGB565;
- ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB565;
- ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_RGB565;
- ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_RGB565;
- break;
-
- case 24:
- ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_RGB888;
- ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_RGB888;
- ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB888;
- ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_RGB888;
- ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB888;
- ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_RGB888;
- ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_RGB888;
- break;
-
- case 32:
- ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_ARGB8888;
- ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_ARGB8888;
- ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB8888;
- ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_ARGB8888;
- ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB8888;
- ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_ARGB8888;
- ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_ARGB8888;
- break;
-
- default:
- break;
- }
-
- switch ( r128ctx->DepthSize ) {
- case 16:
- ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_16;
- ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_16;
- ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_16;
- ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_16;
- break;
-
- case 24:
- ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_24_8;
- ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_24_8;
- ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_24_8;
- ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_24_8;
- break;
-
- case 32:
- ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_32;
- ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_32;
- ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_32;
- ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_32;
- break;
-
- default:
- break;
- }
-
- ctx->Driver.WriteCI8Span = NULL;
- ctx->Driver.WriteCI32Span = NULL;
- ctx->Driver.WriteMonoCISpan = NULL;
- ctx->Driver.WriteCI32Pixels = NULL;
- ctx->Driver.WriteMonoCIPixels = NULL;
- ctx->Driver.ReadCI32Span = NULL;
- ctx->Driver.ReadCI32Pixels = NULL;
+ r128ContextPtr r128ctx = R128_CONTEXT(ctx);
+
+ switch ( r128ctx->BufferSize ) {
+ case 8: /* Color Index mode not supported */
+ break;
+
+ case 15:
+ ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_ARGB1555;
+ ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_ARGB1555;
+ ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB1555;
+ ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_ARGB1555;
+ ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB1555;
+ ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_ARGB1555;
+ ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_ARGB1555;
+ break;
+
+ case 16:
+ ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_RGB565;
+ ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_RGB565;
+ ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB565;
+ ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_RGB565;
+ ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB565;
+ ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_RGB565;
+ ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_RGB565;
+ break;
+
+ case 24:
+ ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_RGB888;
+ ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_RGB888;
+ ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_RGB888;
+ ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_RGB888;
+ ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_RGB888;
+ ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_RGB888;
+ ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_RGB888;
+ break;
+
+ case 32:
+ ctx->Driver.WriteRGBASpan = r128WriteRGBASpan_ARGB8888;
+ ctx->Driver.WriteRGBSpan = r128WriteRGBSpan_ARGB8888;
+ ctx->Driver.WriteMonoRGBASpan = r128WriteMonoRGBASpan_ARGB8888;
+ ctx->Driver.WriteRGBAPixels = r128WriteRGBAPixels_ARGB8888;
+ ctx->Driver.WriteMonoRGBAPixels = r128WriteMonoRGBAPixels_ARGB8888;
+ ctx->Driver.ReadRGBASpan = r128ReadRGBASpan_ARGB8888;
+ ctx->Driver.ReadRGBAPixels = r128ReadRGBAPixels_ARGB8888;
+ break;
+
+ default:
+ break;
+ }
+
+ switch ( r128ctx->DepthSize ) {
+ case 16:
+ ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_16;
+ ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_16;
+ ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_16;
+ ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_16;
+ break;
+
+ case 24:
+ ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_24_8;
+ ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_24_8;
+ ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_24_8;
+ ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_24_8;
+ break;
+
+ case 32:
+ ctx->Driver.ReadDepthSpan = r128ReadDepthSpan_32;
+ ctx->Driver.WriteDepthSpan = r128WriteDepthSpan_32;
+ ctx->Driver.ReadDepthPixels = r128ReadDepthPixels_32;
+ ctx->Driver.WriteDepthPixels = r128WriteDepthPixels_32;
+ break;
+
+ default:
+ break;
+ }
+
+ ctx->Driver.WriteCI8Span = NULL;
+ ctx->Driver.WriteCI32Span = NULL;
+ ctx->Driver.WriteMonoCISpan = NULL;
+ ctx->Driver.WriteCI32Pixels = NULL;
+ ctx->Driver.WriteMonoCIPixels = NULL;
+ ctx->Driver.ReadCI32Span = NULL;
+ ctx->Driver.ReadCI32Pixels = NULL;
}
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_state.c b/xc/lib/GL/mesa/src/drv/r128/r128_state.c
index f130b1b74..50235ea70 100644
--- a/xc/lib/GL/mesa/src/drv/r128/r128_state.c
+++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.c
@@ -714,8 +714,7 @@ static void r128DDSetReadBuffer( GLcontext *ctx,
static void r128DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
{
r128ContextPtr r128ctx = R128_CONTEXT( ctx );
- CARD32 *stipple = (CARD32 *)mask;
- GLuint i;
+ GLuint *stipple = (GLuint *)mask;
FLUSH_BATCH( r128ctx );
ctx->Driver.TriangleCaps |= DD_TRI_STIPPLE;
@@ -730,11 +729,7 @@ static void r128DDPolygonStipple( GLcontext *ctx, const GLubyte *mask )
LOCK_HARDWARE( r128ctx );
- R128CCE0( R128_CCE_PACKET0, R128_BRUSH_DATA0, 31 );
- for ( i = 0 ; i < 32 ; i++ ) {
- R128CCE( stipple[i] );
- }
- R128CCE_SUBMIT_PACKET();
+ drmR128PolygonStipple( r128ctx->driFd, stipple );
UNLOCK_HARDWARE( r128ctx );
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h
index e0334b9df..7c5c5ed43 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h
@@ -1,6 +1,6 @@
/* $XFree86: xc/programs/Xserver/hw/xfree86/drivers/ati/r128.h,v 1.1 2000/11/02 16:55:29 tsi Exp $ */
/*
- * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
+ * Copyright 1999, 2000 ATI Technologies Inc., Markham, Ontario,
* Precision Insight, Inc., Cedar Park, Texas, and
* VA Linux Systems Inc., Fremont, California.
*
@@ -346,8 +346,15 @@ typedef struct {
int backY;
int depthX;
int depthY;
- int textureX;
- int textureY;
+
+ int frontOffset;
+ int frontPitch;
+ int backOffset;
+ int backPitch;
+ int depthOffset;
+ int depthPitch;
+ int spanOffset;
+ int textureOffset;
int textureSize;
int log2TexGran;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c
index bf1fbd5e0..9aafcccb7 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.c
@@ -151,7 +151,11 @@ static Bool R128InitVisualConfigs(ScreenPtr pScreen)
pConfigs[i].stencilSize = 0;
pConfigs[i].auxBuffers = 0;
pConfigs[i].level = 0;
- pConfigs[i].visualRating = GLX_NONE_EXT;
+ if (accum || stencil) {
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ } else {
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ }
pConfigs[i].transparentPixel = GLX_NONE;
pConfigs[i].transparentRed = 0;
pConfigs[i].transparentGreen = 0;
@@ -225,7 +229,11 @@ static Bool R128InitVisualConfigs(ScreenPtr pScreen)
}
pConfigs[i].auxBuffers = 0;
pConfigs[i].level = 0;
- pConfigs[i].visualRating = GLX_NONE_EXT;
+ if (accum || stencil) {
+ pConfigs[i].visualRating = GLX_SLOW_VISUAL_EXT;
+ } else {
+ pConfigs[i].visualRating = GLX_NONE_EXT;
+ }
pConfigs[i].transparentPixel = GLX_NONE;
pConfigs[i].transparentRed = 0;
pConfigs[i].transparentGreen = 0;
@@ -617,9 +625,6 @@ static Bool R128DRIMapInit(R128InfoPtr info, ScreenPtr pScreen)
/* Initialize the kernel data structures. */
static int R128DRIKernelInit(R128InfoPtr info, ScreenPtr pScreen)
{
- ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
- int pitch = pScrn->displayWidth;
- int cpp = info->CurrentLayout.pixel_bytes;
drmR128Init drmInfo;
drmInfo.sarea_priv_offset = sizeof(XF86DRISAREARec);
@@ -632,23 +637,15 @@ static int R128DRIKernelInit(R128InfoPtr info, ScreenPtr pScreen)
drmInfo.fb_bpp = info->CurrentLayout.pixel_code;
drmInfo.depth_bpp = info->CurrentLayout.pixel_code;
- drmInfo.front_offset = (info->fbY * pitch * cpp +
- info->fbX * cpp);
- drmInfo.front_pitch = pitch;
- drmInfo.front_x = info->fbX;
- drmInfo.front_y = info->fbY;
+ drmInfo.front_offset = info->frontOffset;
+ drmInfo.front_pitch = info->frontPitch;
- drmInfo.back_offset = (info->backY * pitch * cpp +
- info->backX * cpp);
- drmInfo.back_pitch = pitch;
- drmInfo.back_x = info->backX;
- drmInfo.back_y = info->backY;
+ drmInfo.back_offset = info->backOffset;
+ drmInfo.back_pitch = info->backPitch;
- drmInfo.depth_offset = (info->depthY * pitch * cpp +
- info->depthX * cpp);
- drmInfo.depth_pitch = pitch;
- drmInfo.depth_x = info->depthX;
- drmInfo.depth_y = info->depthY;
+ drmInfo.depth_offset = info->depthOffset;
+ drmInfo.depth_pitch = info->depthPitch;
+ drmInfo.span_offset = info->spanOffset;
drmInfo.fb_offset = info->LinearAddr;
drmInfo.mmio_offset = info->registerHandle;
@@ -850,12 +847,12 @@ Bool R128DRIScreenInit(ScreenPtr pScreen)
version = drmGetVersion(info->drmFD);
if (version) {
if (version->version_major != 2 ||
- version->version_minor != 0 ||
+ version->version_minor != 1 ||
version->version_patchlevel < 0) {
/* incompatible drm version */
xf86DrvMsg(pScreen->myNum, X_ERROR,
"R128DRIScreenInit failed "
- "(DRM version = %d.%d.%d, expected 2.0.x). "
+ "(DRM version = %d.%d.%d, expected 2.1.x). "
"Disabling DRI.\n",
version->version_major,
version->version_minor,
@@ -971,14 +968,14 @@ Bool R128DRIFinishScreenInit(ScreenPtr pScreen)
pR128DRI->depth = pScrn->depth;
pR128DRI->bpp = pScrn->bitsPerPixel;
- pR128DRI->fbX = info->fbX;
- pR128DRI->fbY = info->fbY;
- pR128DRI->backX = info->backX;
- pR128DRI->backY = info->backY;
- pR128DRI->depthX = info->depthX;
- pR128DRI->depthY = info->depthY;
- pR128DRI->textureX = info->textureX;
- pR128DRI->textureY = info->textureY;
+ pR128DRI->frontOffset = info->frontOffset;
+ pR128DRI->frontPitch = info->frontPitch;
+ pR128DRI->backOffset = info->backOffset;
+ pR128DRI->backPitch = info->backPitch;
+ pR128DRI->depthOffset = info->depthOffset;
+ pR128DRI->depthPitch = info->depthPitch;
+ pR128DRI->spanOffset = info->spanOffset;
+ pR128DRI->textureOffset = info->textureOffset;
pR128DRI->textureSize = info->textureSize;
pR128DRI->log2TexGran = info->log2TexGran;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h
index 51120d943..f0ae02c7e 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_dri.h
@@ -97,14 +97,14 @@ typedef struct {
int depth; /* Depth of display (8, 15, 16, 24) */
int bpp; /* Bit depth of display (8, 16, 24, 32) */
- int fbX; /* Start of frame buffer */
- int fbY;
- int backX; /* Start of shared back buffer */
- int backY;
- int depthX; /* Start of shared depth buffer */
- int depthY;
- int textureX; /* Start of texture data in frame buffer */
- int textureY;
+ int frontOffset; /* Start of front buffer */
+ int frontPitch;
+ int backOffset; /* Start of shared back buffer */
+ int backPitch;
+ int depthOffset; /* Start of shared depth buffer */
+ int depthPitch;
+ int spanOffset; /* Start of scratch spanline */
+ int textureOffset;/* Start of texture data in frame buffer */
int textureSize;
int log2TexGran;
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c
index 33719736c..15eb26662 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_driver.c
@@ -1412,7 +1412,6 @@ Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
ScrnInfoPtr pScrn = xf86Screens[pScreen->myNum];
R128InfoPtr info = R128PTR(pScrn);
BoxRec MemBox;
- int y2;
R128TRACE(("R128ScreenInit %x %d\n", pScrn->memPhysBase, pScrn->fbOffset));
@@ -1426,6 +1425,8 @@ Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
#ifdef XF86DRI
info->fbX = 0;
info->fbY = 0;
+ info->frontOffset = 0;
+ info->frontPitch = pScrn->displayWidth;
#endif
info->PaletteSavedOnVT = FALSE;
@@ -1462,21 +1463,26 @@ Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
info->CurrentLayout.pixel_bytes);
int maxy = info->FbMapSize / width_bytes;
- if (!xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE) &&
- (maxy > pScrn->virtualY * 3)
-#if 0
+ if (xf86ReturnOptValBool(R128Options, OPTION_NOACCEL, FALSE)) {
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "Acceleration disabled, not initializing the DRI");
+ info->directRenderingEnabled = FALSE;
+#if 1
+ } else if (info->HasPanelRegs) {
/* FIXME: Disable 3D support for FPs until it is tested */
- && !info->HasPanelRegs
+ xf86DrvMsg(scrnIndex, X_WARNING,
+ "DRI disabled on Mobility 128 by default");
+ info->directRenderingEnabled = FALSE;
#endif
- ) {
- info->directRenderingEnabled = R128DRIScreenInit(pScreen);
- } else {
+ } else if (maxy <= pScrn->virtualY * 3) {
xf86DrvMsg(scrnIndex, X_WARNING,
"Static buffer allocation failed -- "
"need at least %d kB video memory\n",
(pScrn->displayWidth * pScrn->virtualY *
info->CurrentLayout.pixel_bytes * 3 + 1023) / 1024);
info->directRenderingEnabled = FALSE;
+ } else {
+ info->directRenderingEnabled = R128DRIScreenInit(pScreen);
}
}
#endif
@@ -1552,165 +1558,205 @@ Bool R128ScreenInit(int scrnIndex, ScreenPtr pScreen, int argc, char **argv)
R128DGAInit(pScreen);
/* Memory manager setup */
- MemBox.x1 = 0;
- MemBox.y1 = 0;
- MemBox.x2 = pScrn->displayWidth;
- y2 = (info->FbMapSize
- / (pScrn->displayWidth * info->CurrentLayout.pixel_bytes));
- if (y2 >= 32768) y2 = 32767; /* because MemBox.y2 is signed short */
- MemBox.y2 = y2;
-
- /* The acceleration engine uses 14 bit
- signed coordinates, so we can't have any
- drawable caches beyond this region. */
- if (MemBox.y2 > 8191) MemBox.y2 = 8191;
-
- if (!xf86InitFBManager(pScreen, &MemBox)) {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Memory manager initialization to (%d,%d) (%d,%d) failed\n",
- MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2);
- return FALSE;
- } else {
- int width, height;
- FBAreaPtr fbarea;
-
- xf86DrvMsg(scrnIndex, X_INFO,
- "Memory manager initialized to (%d,%d) (%d,%d)\n",
- MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2);
- if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth,
- 2, 0, NULL, NULL, NULL))) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Reserved area from (%d,%d) to (%d,%d)\n",
- fbarea->box.x1, fbarea->box.y1,
- fbarea->box.x2, fbarea->box.y2);
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve area\n");
- }
- if (xf86QueryLargestOffscreenArea(pScreen, &width, &height, 0, 0, 0)) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Largest offscreen area available: %d x %d\n",
- width, height);
- }
- }
-
#ifdef XF86DRI
- /* Allocate frame buffer space for the
- shared back and depth buffers as well
- as for local textures. */
if (info->directRenderingEnabled) {
- FBAreaPtr fbarea;
- int width_bytes = (pScrn->displayWidth *
- info->CurrentLayout.pixel_bytes);
- int maxy = info->FbMapSize / width_bytes;
- int l;
-
- switch (info->CCEMode) {
- case R128_DEFAULT_CCE_PIO_MODE:
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in PIO mode\n");
- break;
- case R128_DEFAULT_CCE_BM_MODE:
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in BM mode\n");
- break;
- default:
- xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in UNKNOWN mode\n");
- break;
- }
-
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Using %d MB AGP aperture\n", info->agpSize);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Using %d MB for the ring buffer\n", info->ringSize);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Using %d MB for vertex/indirect buffers\n", info->bufSize);
- xf86DrvMsg(pScrn->scrnIndex, X_INFO,
- "Using %d MB for AGP textures\n", info->agpTexSize);
+ FBAreaPtr fbarea;
+ int width_bytes = (pScrn->displayWidth *
+ info->CurrentLayout.pixel_bytes);
+ int cpp = info->CurrentLayout.pixel_bytes;
+ int bufferSize = pScrn->virtualY * width_bytes;
+ int l, total;
+ int scanlines;
+
+ switch (info->CCEMode) {
+ case R128_DEFAULT_CCE_PIO_MODE:
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in PIO mode\n");
+ break;
+ case R128_DEFAULT_CCE_BM_MODE:
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in BM mode\n");
+ break;
+ default:
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO, "CCE in UNKNOWN mode\n");
+ break;
+ }
+
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Using %d MB AGP aperture\n", info->agpSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Using %d MB for the ring buffer\n", info->ringSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Using %d MB for vertex/indirect buffers\n", info->bufSize);
+ xf86DrvMsg(pScrn->scrnIndex, X_INFO,
+ "Using %d MB for AGP textures\n", info->agpTexSize);
+
+ /* Try for front, back, depth, and two framebuffers worth of
+ * pixmap cache. Should be enough for a fullscreen background
+ * image plus some leftovers.
+ */
+ info->textureSize = info->FbMapSize - 5 * bufferSize;
+
+ /* If that gives us less than half the available memory, let's
+ * be greedy and grab some more. Sorry, I care more about 3D
+ * performance than playing nicely, and you'll get around a full
+ * framebuffer's worth of pixmap cache anyway.
+ */
+ if ( info->textureSize < info->FbMapSize / 2 ) {
+ info->textureSize = info->FbMapSize - 4 * bufferSize;
+ }
+
+ l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
+ if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
+
+ /* Round the texture size up to the nearest whole number of
+ * texture regions. Again, be greedy about this, don't round
+ * down.
+ */
+ info->log2TexGran = l;
+ info->textureSize = ((info->textureSize >> l) + 1) << l;
+
+ total = info->FbMapSize - info->textureSize;
+ scanlines = total / width_bytes;
+ if (scanlines > 8191) scanlines = 8191;
+
+ /* Recalculate the texture offset and size to accomodate any
+ * rounding to a whole number of scanlines.
+ * FIXME: Is this actually needed?
+ */
+ info->textureOffset = scanlines * width_bytes;
+ info->textureSize = info->FbMapSize - info->textureOffset;
+
+ MemBox.x1 = 0;
+ MemBox.y1 = 0;
+ MemBox.x2 = pScrn->displayWidth;
+ MemBox.y2 = scanlines;
+
+ if (!xf86InitFBManager(pScreen, &MemBox)) {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Memory manager initialization to (%d,%d) (%d,%d) failed\n",
+ MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2);
+ return FALSE;
+ } else {
+ int width, height;
+
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Memory manager initialized to (%d,%d) (%d,%d)\n",
+ MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2);
+ if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth,
+ 2, 0, NULL, NULL, NULL))) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved area from (%d,%d) to (%d,%d)\n",
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve area\n");
+ }
+ if (xf86QueryLargestOffscreenArea(pScreen, &width,
+ &height, 0, 0, 0)) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Largest offscreen area available: %d x %d\n",
+ width, height);
+ }
+ }
/* Allocate the shared back buffer */
- if ((fbarea = xf86AllocateOffscreenArea(pScreen,
- pScrn->virtualX,
- pScrn->virtualY,
- 32, NULL, NULL, NULL))) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Reserved back buffer from (%d,%d) to (%d,%d)\n",
- fbarea->box.x1, fbarea->box.y1,
- fbarea->box.x2, fbarea->box.y2);
-
- info->backX = fbarea->box.x1;
- info->backY = fbarea->box.y1;
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n");
- info->backX = -1;
- info->backY = -1;
- }
+ if ((fbarea = xf86AllocateOffscreenArea(pScreen,
+ pScrn->virtualX,
+ pScrn->virtualY,
+ 32, NULL, NULL, NULL))) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved back buffer from (%d,%d) to (%d,%d)\n",
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+
+ info->backX = fbarea->box.x1;
+ info->backY = fbarea->box.y1;
+ info->backOffset = (fbarea->box.y1 * width_bytes +
+ fbarea->box.x1 * cpp);
+ info->backPitch = pScrn->displayWidth;
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve back buffer\n");
+ info->backX = -1;
+ info->backY = -1;
+ info->backOffset = -1;
+ info->backPitch = -1;
+ }
/* Allocate the shared depth buffer */
- if ((fbarea = xf86AllocateOffscreenArea(pScreen,
- pScrn->virtualX,
- pScrn->virtualY,
- 32, NULL, NULL, NULL))) {
- xf86DrvMsg(scrnIndex, X_INFO,
- "Reserved depth buffer from (%d,%d) to (%d,%d)\n",
- fbarea->box.x1, fbarea->box.y1,
- fbarea->box.x2, fbarea->box.y2);
+ if ((fbarea = xf86AllocateOffscreenArea(pScreen,
+ pScrn->virtualX,
+ pScrn->virtualY + 1,
+ 32, NULL, NULL, NULL))) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved depth buffer from (%d,%d) to (%d,%d)\n",
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+
+ info->depthX = fbarea->box.x1;
+ info->depthY = fbarea->box.y1;
+ info->depthOffset = (fbarea->box.y1 * width_bytes +
+ fbarea->box.x1 * cpp);
+ info->depthPitch = pScrn->displayWidth;
+ info->spanOffset = ((fbarea->box.y2 - 1) * width_bytes +
+ fbarea->box.x1 * cpp);
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved depth span from (%d,%d) offset 0x%x\n",
+ fbarea->box.x1, fbarea->box.y2 - 1, info->spanOffset);
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n");
+ info->depthX = -1;
+ info->depthY = -1;
+ info->depthOffset = -1;
+ info->depthPitch = -1;
+ info->spanOffset = -1;
+ }
+
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved %d kb for textures at offset 0x%x\n",
+ info->textureSize/1024, total);
+ }
+ else
+#endif
+ {
+ MemBox.x1 = 0;
+ MemBox.y1 = 0;
+ MemBox.x2 = pScrn->displayWidth;
+ MemBox.y2 = (info->FbMapSize
+ / (pScrn->displayWidth *
+ info->CurrentLayout.pixel_bytes));
+ /* The acceleration engine uses 14 bit
+ signed coordinates, so we can't have any
+ drawable caches beyond this region. */
+ if (MemBox.y2 > 8191) MemBox.y2 = 8191;
- info->depthX = fbarea->box.x1;
- info->depthY = fbarea->box.y1;
+ if (!xf86InitFBManager(pScreen, &MemBox)) {
+ xf86DrvMsg(scrnIndex, X_ERROR,
+ "Memory manager initialization to (%d,%d) (%d,%d) failed\n",
+ MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2);
+ return FALSE;
} else {
- xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve depth buffer\n");
- info->depthX = -1;
- info->depthY = -1;
- }
-
- /* Allocate local texture space */
- if (((maxy - MemBox.y2 - 1) * width_bytes) >
- (pScrn->virtualX * pScrn->virtualY * 2 *
- info->CurrentLayout.pixel_bytes)) {
- info->textureX = 0;
- info->textureY = MemBox.y2 + 1;
- info->textureSize = (maxy - MemBox.y2 - 1) * width_bytes;
-
- l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
- if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
-
- info->log2TexGran = l;
- info->textureSize = (info->textureSize >> l) << l;
-
- xf86DrvMsg(scrnIndex, X_INFO,
- "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n",
- info->textureSize/1024,
- info->textureX, info->textureY,
- pScrn->displayWidth, maxy);
- } else if ((fbarea = xf86AllocateOffscreenArea(pScreen,
- pScrn->virtualX,
- pScrn->virtualY * 2,
- 32,
- NULL, NULL, NULL))) {
- info->textureX = fbarea->box.x1;
- info->textureY = fbarea->box.y1;
- info->textureSize = ((fbarea->box.y2 - fbarea->box.y1) *
- (fbarea->box.x2 - fbarea->box.x1) *
- info->CurrentLayout.pixel_bytes);
-
- l = R128MinBits((info->textureSize-1) / R128_NR_TEX_REGIONS);
- if (l < R128_LOG_TEX_GRANULARITY) l = R128_LOG_TEX_GRANULARITY;
-
- info->log2TexGran = l;
- info->textureSize = (info->textureSize >> l) << l;
+ int width, height;
+ FBAreaPtr fbarea;
xf86DrvMsg(scrnIndex, X_INFO,
- "Reserved %d kb for textures: (%d,%d)-(%d,%d)\n",
- info->textureSize/1024,
- fbarea->box.x1, fbarea->box.y1,
- fbarea->box.x2, fbarea->box.y2);
- } else {
- xf86DrvMsg(scrnIndex, X_ERROR,
- "Unable to reserve texture space in frame buffer\n");
- info->textureX = -1;
- info->textureY = -1;
+ "Memory manager initialized to (%d,%d) (%d,%d)\n",
+ MemBox.x1, MemBox.y1, MemBox.x2, MemBox.y2);
+ if ((fbarea = xf86AllocateOffscreenArea(pScreen, pScrn->displayWidth,
+ 2, 0, NULL, NULL, NULL))) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Reserved area from (%d,%d) to (%d,%d)\n",
+ fbarea->box.x1, fbarea->box.y1,
+ fbarea->box.x2, fbarea->box.y2);
+ } else {
+ xf86DrvMsg(scrnIndex, X_ERROR, "Unable to reserve area\n");
+ }
+ if (xf86QueryLargestOffscreenArea(pScreen, &width, &height,
+ 0, 0, 0)) {
+ xf86DrvMsg(scrnIndex, X_INFO,
+ "Largest offscreen area available: %d x %d\n",
+ width, height);
+ }
}
}
-#endif
-
/* Backing store setup */
miInitializeBackingStore(pScreen);
xf86SetBackingStore(pScreen);
diff --git a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h
index c9716117a..ea4b8a569 100644
--- a/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h
+++ b/xc/programs/Xserver/hw/xfree86/drivers/ati/r128_sarea.h
@@ -95,7 +95,7 @@
#define R128_LOCAL_TEX_HEAP 0
#define R128_AGP_TEX_HEAP 1
#define R128_NR_TEX_HEAPS 2
-#define R128_NR_TEX_REGIONS 16
+#define R128_NR_TEX_REGIONS 64
#define R128_LOG_TEX_GRANULARITY 16
#define R128_NR_CONTEXT_REGS 12
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
index 5d3834272..20691ccf2 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/drm.h
@@ -374,7 +374,9 @@ typedef struct drm_agp_info {
#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x49, drm_r128_vertex_t)
#define DRM_IOCTL_R128_INDICES DRM_IOW( 0x4a, drm_r128_indices_t)
#define DRM_IOCTL_R128_BLIT DRM_IOW( 0x4b, drm_r128_blit_t)
-#define DRM_IOCTL_R128_PACKET DRM_IOWR(0x4c, drm_r128_packet_t)
+#define DRM_IOCTL_R128_DEPTH DRM_IOW( 0x4c, drm_r128_depth_t)
+#define DRM_IOCTL_R128_STIPPLE DRM_IOW( 0x4d, drm_r128_stipple_t)
+#define DRM_IOCTL_R128_PACKET DRM_IOWR(0x4e, drm_r128_packet_t)
/* SiS specific ioctls */
#define SIS_IOCTL_FB_ALLOC DRM_IOWR( 0x44, drm_sis_mem_t)
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 cab9acd61..0b1576a90 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
@@ -437,18 +437,13 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv->fb_bpp = init->fb_bpp;
dev_priv->front_offset = init->front_offset;
dev_priv->front_pitch = init->front_pitch;
- dev_priv->front_x = init->front_x;
- dev_priv->front_y = init->front_y;
dev_priv->back_offset = init->back_offset;
dev_priv->back_pitch = init->back_pitch;
- dev_priv->back_x = init->back_x;
- dev_priv->back_y = init->back_y;
dev_priv->depth_bpp = init->depth_bpp;
dev_priv->depth_offset = init->depth_offset;
dev_priv->depth_pitch = init->depth_pitch;
- dev_priv->depth_x = init->depth_x;
- dev_priv->depth_y = init->depth_y;
+ dev_priv->span_offset = init->span_offset;
dev_priv->front_pitch_offset_c = (((dev_priv->front_pitch/8) << 21) |
(dev_priv->front_offset >> 5));
@@ -457,6 +452,8 @@ static int r128_do_init_cce( drm_device_t *dev, drm_r128_init_t *init )
dev_priv->depth_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) |
(dev_priv->depth_offset >> 5) |
R128_DST_TILE);
+ dev_priv->span_pitch_offset_c = (((dev_priv->depth_pitch/8) << 21) |
+ (dev_priv->span_offset >> 5));
/* FIXME: We want multiple shared areas, including one shared
* only by the X Server and kernel module.
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h
index 51e31cd34..b81d2fca2 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_drm.h
@@ -94,7 +94,7 @@
#define R128_LOCAL_TEX_HEAP 0
#define R128_AGP_TEX_HEAP 1
#define R128_NR_TEX_HEAPS 2
-#define R128_NR_TEX_REGIONS 16
+#define R128_NR_TEX_REGIONS 64
#define R128_LOG_TEX_GRANULARITY 16
#define R128_NR_CONTEXT_REGS 12
@@ -196,12 +196,10 @@ typedef struct drm_r128_init {
unsigned int fb_bpp;
unsigned int front_offset, front_pitch;
- unsigned int front_x, front_y;
unsigned int back_offset, back_pitch;
- unsigned int back_x, back_y;
unsigned int depth_bpp;
unsigned int depth_offset, depth_pitch;
- unsigned int depth_x, depth_y;
+ unsigned int span_offset;
unsigned int fb_offset;
unsigned int mmio_offset;
@@ -249,6 +247,24 @@ typedef struct drm_r128_blit {
unsigned short width, height;
} drm_r128_blit_t;
+typedef struct drm_r128_depth {
+ enum {
+ R128_WRITE_SPAN = 0x01,
+ R128_WRITE_PIXELS = 0x02,
+ R128_READ_SPAN = 0x03,
+ R128_READ_PIXELS = 0x04
+ } func;
+ int n;
+ int *x;
+ int *y;
+ unsigned int *buffer;
+ unsigned char *mask;
+} drm_r128_depth_t;
+
+typedef struct drm_r128_stipple {
+ unsigned int *mask;
+} drm_r128_stipple_t;
+
typedef struct drm_r128_packet {
unsigned int *buffer;
int count;
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 f73d4c0b8..89b68696e 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
@@ -37,10 +37,10 @@
#define R128_NAME "r128"
#define R128_DESC "ATI Rage 128"
-#define R128_DATE "20001129"
+#define R128_DATE "20001201"
#define R128_MAJOR 2
-#define R128_MINOR 0
-#define R128_PATCHLEVEL 1
+#define R128_MINOR 1
+#define R128_PATCHLEVEL 0
static drm_device_t r128_device;
drm_ctx_t r128_res_ctx;
@@ -119,6 +119,8 @@ static drm_ioctl_desc_t r128_ioctls[] = {
[DRM_IOCTL_NR(DRM_IOCTL_R128_VERTEX)] = { r128_cce_vertex, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_R128_INDICES)] = { r128_cce_indices, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_R128_BLIT)] = { r128_cce_blit, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_DEPTH)] = { r128_cce_depth, 1, 0 },
+ [DRM_IOCTL_NR(DRM_IOCTL_R128_STIPPLE)] = { r128_cce_stipple, 1, 0 },
[DRM_IOCTL_NR(DRM_IOCTL_R128_PACKET)] = { r128_cce_packet, 1, 0 },
};
#define R128_IOCTL_COUNT DRM_ARRAY_SIZE(r128_ioctls)
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 1aa6bde58..cffd08002 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
@@ -73,22 +73,18 @@ typedef struct drm_r128_private {
unsigned int fb_bpp;
unsigned int front_offset;
unsigned int front_pitch;
- unsigned int front_x;
- unsigned int front_y;
unsigned int back_offset;
unsigned int back_pitch;
- unsigned int back_x;
- unsigned int back_y;
unsigned int depth_bpp;
unsigned int depth_offset;
unsigned int depth_pitch;
- unsigned int depth_x;
- unsigned int depth_y;
+ unsigned int span_offset;
u32 front_pitch_offset_c;
u32 back_pitch_offset_c;
u32 depth_pitch_offset_c;
+ u32 span_pitch_offset_c;
drm_map_t *sarea;
drm_map_t *fb;
@@ -154,6 +150,10 @@ extern int r128_cce_indices( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
extern int r128_cce_blit( struct inode *inode, struct file *filp,
unsigned int cmd, unsigned long arg );
+extern int r128_cce_depth( struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg );
+extern int r128_cce_stipple( struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg );
/* r128_bufs.c */
extern int r128_addbufs(struct inode *inode, struct file *filp,
@@ -208,6 +208,7 @@ extern int r128_context_switch_complete(drm_device_t *dev, int new);
#define R128_AUX3_SC_TOP 0x168c
#define R128_AUX3_SC_BOTTOM 0x1690
+#define R128_BRUSH_DATA0 0x1480
#define R128_BUS_CNTL 0x0030
# define R128_BUS_MASTER_DIS (1 << 6)
@@ -425,7 +426,7 @@ extern int R128_READ_PLL(drm_device_t *dev, int addr);
#define R128_VERBOSE 0
-#define RING_LOCALS int write; unsigned int mask; volatile u32 *ring;
+#define RING_LOCALS int write; unsigned int tail_mask; volatile u32 *ring;
#define BEGIN_RING( n ) do { \
if ( R128_VERBOSE ) { \
@@ -438,7 +439,7 @@ extern int R128_READ_PLL(drm_device_t *dev, int addr);
dev_priv->ring.space -= n * sizeof(u32); \
ring = dev_priv->ring.start; \
write = dev_priv->ring.tail; \
- mask = dev_priv->ring.tail_mask; \
+ tail_mask = dev_priv->ring.tail_mask; \
} while (0)
#define ADVANCE_RING() do { \
@@ -457,7 +458,7 @@ extern int R128_READ_PLL(drm_device_t *dev, int addr);
(unsigned int)(x), write ); \
} \
ring[write++] = x; \
- write &= mask; \
+ write &= tail_mask; \
} while (0)
#define R128_PERFORMANCE_BOXES 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 6671518f6..faad25a2d 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
@@ -534,10 +534,10 @@ static void r128_cce_dispatch_swap( drm_device_t *dev )
OUT_RING( R128_GMC_SRC_PITCH_OFFSET_CNTL
| R128_GMC_DST_PITCH_OFFSET_CNTL
| R128_GMC_BRUSH_NONE
- | R128_GMC_SRC_DATATYPE_COLOR
- | R128_DP_SRC_SOURCE_MEMORY
| fb_bpp
+ | R128_GMC_SRC_DATATYPE_COLOR
| R128_ROP3_S
+ | R128_DP_SRC_SOURCE_MEMORY
| R128_GMC_CLR_CMP_CNTL_DIS
| R128_GMC_AUX_CLIP_DIS
| R128_GMC_WR_MSK_DIS );
@@ -550,12 +550,12 @@ static void r128_cce_dispatch_swap( drm_device_t *dev )
OUT_RING( (x << 16) | y );
OUT_RING( (w << 16) | h );
#else
- OUT_RING( dev_priv->depth_pitch_offset_c & ~R128_DST_TILE );
+ OUT_RING( dev_priv->depth_pitch_offset_c /*& ~R128_DST_TILE*/ );
OUT_RING( dev_priv->front_pitch_offset_c );
OUT_RING( (0 << 16) | 0 );
OUT_RING( (0 << 16) | 0 );
- OUT_RING( (1024 << 16) | 768 );
+ OUT_RING( (800 << 16) | 600 );
#endif
ADVANCE_RING();
@@ -581,9 +581,7 @@ static void r128_cce_dispatch_vertex( drm_device_t *dev,
drm_r128_private_t *dev_priv = dev->dev_private;
drm_r128_buf_priv_t *buf_priv = buf->dev_private;
drm_r128_sarea_t *sarea_priv = dev_priv->sarea_priv;
- int vertsize = sarea_priv->vertsize;
int format = sarea_priv->vc_format;
- int index = buf->idx;
int offset = dev_priv->buffers->offset + buf->offset - dev->agp->base;
int size = buf->used;
int prim = buf_priv->prim;
@@ -691,21 +689,6 @@ static void r128_cce_dispatch_indirect( drm_device_t *dev,
data[dwords++] = R128_CCE_PACKET2;
}
- DRM_DEBUG( "indirect: offset=0x%x dwords=%d\n",
- offset, dwords );
-
- if ( 0 ) {
- u32 *data = (u32 *)
- ((char *)dev_priv->buffers->handle
- + buf->offset + start);
- int i;
- DRM_INFO( "data = %p\n", data );
- for ( i = 0 ; i < dwords ; i++ ) {
- DRM_INFO( "data[0x%x] = 0x%08x\n",
- i, data[i] );
- }
- }
-
buf_priv->dispatched = 1;
/* Fire off the indirect buffer */
@@ -941,7 +924,422 @@ static int r128_cce_dispatch_blit( drm_device_t *dev,
/* ================================================================
- *
+ * Tiled depth buffer management
+ */
+
+static int r128_cce_dispatch_write_span( drm_device_t *dev,
+ drm_r128_depth_t *depth )
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int count, x, y;
+ u32 *buffer;
+ u8 *mask;
+ u32 depth_bpp;
+ int i;
+ RING_LOCALS;
+ DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+ r128_update_ring_snapshot( dev_priv );
+
+ switch ( dev_priv->depth_bpp ) {
+ case 16:
+ depth_bpp = R128_GMC_DST_16BPP;
+ break;
+ case 24:
+ depth_bpp = R128_GMC_DST_32BPP;
+ break;
+ case 32:
+ depth_bpp = R128_GMC_DST_32BPP;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ count = depth->n;
+ if ( copy_from_user( &x, depth->x, sizeof(x) ) ) {
+ return -EFAULT;
+ }
+ if ( copy_from_user( &y, depth->y, sizeof(y) ) ) {
+ return -EFAULT;
+ }
+
+ buffer = kmalloc( depth->n * sizeof(u32), 0 );
+ if ( buffer == NULL )
+ return -ENOMEM;
+ if ( copy_from_user( buffer, depth->buffer,
+ depth->n * sizeof(u32) ) ) {
+ kfree( buffer );
+ return -EFAULT;
+ }
+
+ if ( depth->mask ) {
+ mask = kmalloc( depth->n * sizeof(u8), 0 );
+ if ( mask == NULL ) {
+ kfree( buffer );
+ return -ENOMEM;
+ }
+ if ( copy_from_user( mask, depth->mask,
+ depth->n * sizeof(u8) ) ) {
+ kfree( buffer );
+ kfree( mask );
+ return -EFAULT;
+ }
+
+ for ( i = 0 ; i < count ; i++, x++ ) {
+ if ( mask[i] ) {
+ BEGIN_RING( 6 );
+
+ OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI,
+ 4 ) );
+ OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL
+ | R128_GMC_BRUSH_SOLID_COLOR
+ | depth_bpp
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | R128_ROP3_P
+ | R128_GMC_CLR_CMP_CNTL_DIS
+ | R128_GMC_WR_MSK_DIS );
+
+ OUT_RING( dev_priv->depth_pitch_offset_c );
+ OUT_RING( buffer[i] );
+
+ OUT_RING( (x << 16) | y );
+ OUT_RING( (1 << 16) | 1 );
+
+ ADVANCE_RING();
+ }
+ }
+
+ kfree( mask );
+ } else {
+ for ( i = 0 ; i < count ; i++, x++ ) {
+ BEGIN_RING( 6 );
+
+ OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, 4 ) );
+ OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL
+ | R128_GMC_BRUSH_SOLID_COLOR
+ | depth_bpp
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | R128_ROP3_P
+ | R128_GMC_CLR_CMP_CNTL_DIS
+ | R128_GMC_WR_MSK_DIS );
+
+ OUT_RING( dev_priv->depth_pitch_offset_c );
+ OUT_RING( buffer[i] );
+
+ OUT_RING( (x << 16) | y );
+ OUT_RING( (1 << 16) | 1 );
+
+ ADVANCE_RING();
+ }
+ }
+
+ kfree( buffer );
+
+ return 0;
+}
+
+static int r128_cce_dispatch_write_pixels( drm_device_t *dev,
+ drm_r128_depth_t *depth )
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int count, *x, *y;
+ u32 *buffer;
+ u8 *mask;
+ u32 depth_bpp;
+ int i;
+ RING_LOCALS;
+ DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+ r128_update_ring_snapshot( dev_priv );
+
+ switch ( dev_priv->depth_bpp ) {
+ case 16:
+ depth_bpp = R128_GMC_DST_16BPP;
+ break;
+ case 24:
+ depth_bpp = R128_GMC_DST_32BPP;
+ break;
+ case 32:
+ depth_bpp = R128_GMC_DST_32BPP;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ count = depth->n;
+
+ x = kmalloc( count * sizeof(*x), 0 );
+ if ( x == NULL ) {
+ return -ENOMEM;
+ }
+ y = kmalloc( count * sizeof(*y), 0 );
+ if ( y == NULL ) {
+ kfree( x );
+ return -ENOMEM;
+ }
+ if ( copy_from_user( x, depth->x, count * sizeof(int) ) ) {
+ kfree( x );
+ kfree( y );
+ return -EFAULT;
+ }
+ if ( copy_from_user( y, depth->y, count * sizeof(int) ) ) {
+ kfree( x );
+ kfree( y );
+ return -EFAULT;
+ }
+
+ buffer = kmalloc( depth->n * sizeof(u32), 0 );
+ if ( buffer == NULL ) {
+ kfree( x );
+ kfree( y );
+ return -ENOMEM;
+ }
+ if ( copy_from_user( buffer, depth->buffer,
+ depth->n * sizeof(u32) ) ) {
+ kfree( x );
+ kfree( y );
+ kfree( buffer );
+ return -EFAULT;
+ }
+
+ if ( depth->mask ) {
+ mask = kmalloc( depth->n * sizeof(u8), 0 );
+ if ( mask == NULL ) {
+ kfree( x );
+ kfree( y );
+ kfree( buffer );
+ return -ENOMEM;
+ }
+ if ( copy_from_user( mask, depth->mask,
+ depth->n * sizeof(u8) ) ) {
+ kfree( x );
+ kfree( y );
+ kfree( buffer );
+ kfree( mask );
+ return -EFAULT;
+ }
+
+ for ( i = 0 ; i < count ; i++ ) {
+ if ( mask[i] ) {
+ BEGIN_RING( 6 );
+
+ OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI,
+ 4 ) );
+ OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL
+ | R128_GMC_BRUSH_SOLID_COLOR
+ | depth_bpp
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | R128_ROP3_P
+ | R128_GMC_CLR_CMP_CNTL_DIS
+ | R128_GMC_WR_MSK_DIS );
+
+ OUT_RING( dev_priv->depth_pitch_offset_c );
+ OUT_RING( buffer[i] );
+
+ OUT_RING( (x[i] << 16) | y[i] );
+ OUT_RING( (1 << 16) | 1 );
+
+ ADVANCE_RING();
+ }
+ }
+
+ kfree( mask );
+ } else {
+ for ( i = 0 ; i < count ; i++ ) {
+ BEGIN_RING( 6 );
+
+ OUT_RING( CCE_PACKET3( R128_CNTL_PAINT_MULTI, 4 ) );
+ OUT_RING( R128_GMC_DST_PITCH_OFFSET_CNTL
+ | R128_GMC_BRUSH_SOLID_COLOR
+ | depth_bpp
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | R128_ROP3_P
+ | R128_GMC_CLR_CMP_CNTL_DIS
+ | R128_GMC_WR_MSK_DIS );
+
+ OUT_RING( dev_priv->depth_pitch_offset_c );
+ OUT_RING( buffer[i] );
+
+ OUT_RING( (x[i] << 16) | y[i] );
+ OUT_RING( (1 << 16) | 1 );
+
+ ADVANCE_RING();
+ }
+ }
+
+ kfree( x );
+ kfree( y );
+ kfree( buffer );
+
+ return 0;
+}
+
+static int r128_cce_dispatch_read_span( drm_device_t *dev,
+ drm_r128_depth_t *depth )
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int count, x, y;
+ u32 depth_bpp;
+ RING_LOCALS;
+ DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+ r128_update_ring_snapshot( dev_priv );
+
+ switch ( dev_priv->depth_bpp ) {
+ case 16:
+ depth_bpp = R128_GMC_DST_16BPP;
+ break;
+ case 24:
+ depth_bpp = R128_GMC_DST_32BPP;
+ break;
+ case 32:
+ depth_bpp = R128_GMC_DST_32BPP;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ count = depth->n;
+ if ( copy_from_user( &x, depth->x, sizeof(x) ) ) {
+ return -EFAULT;
+ }
+ if ( copy_from_user( &y, depth->y, sizeof(y) ) ) {
+ return -EFAULT;
+ }
+
+ BEGIN_RING( 7 );
+
+ OUT_RING( CCE_PACKET3( R128_CNTL_BITBLT_MULTI, 5 ) );
+ OUT_RING( R128_GMC_SRC_PITCH_OFFSET_CNTL
+ | R128_GMC_DST_PITCH_OFFSET_CNTL
+ | R128_GMC_BRUSH_NONE
+ | depth_bpp
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | R128_ROP3_S
+ | R128_DP_SRC_SOURCE_MEMORY
+ | R128_GMC_CLR_CMP_CNTL_DIS
+ | R128_GMC_WR_MSK_DIS );
+
+ OUT_RING( dev_priv->depth_pitch_offset_c );
+ OUT_RING( dev_priv->span_pitch_offset_c );
+
+ OUT_RING( (x << 16) | y );
+ OUT_RING( (0 << 16) | 0 );
+ OUT_RING( (count << 16) | 1 );
+
+ ADVANCE_RING();
+
+ return 0;
+}
+
+static int r128_cce_dispatch_read_pixels( drm_device_t *dev,
+ drm_r128_depth_t *depth )
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int count, *x, *y;
+ u32 depth_bpp;
+ int i;
+ RING_LOCALS;
+ DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+ r128_update_ring_snapshot( dev_priv );
+
+ switch ( dev_priv->depth_bpp ) {
+ case 16:
+ depth_bpp = R128_GMC_DST_16BPP;
+ break;
+ case 24:
+ depth_bpp = R128_GMC_DST_32BPP;
+ break;
+ case 32:
+ depth_bpp = R128_GMC_DST_32BPP;
+ break;
+ default:
+ return -EINVAL;
+ }
+
+ count = depth->n;
+ if ( count > dev_priv->depth_pitch ) {
+ count = dev_priv->depth_pitch;
+ }
+
+ x = kmalloc( count * sizeof(*x), 0 );
+ if ( x == NULL ) {
+ return -ENOMEM;
+ }
+ y = kmalloc( count * sizeof(*y), 0 );
+ if ( y == NULL ) {
+ kfree( x );
+ return -ENOMEM;
+ }
+ if ( copy_from_user( x, depth->x, count * sizeof(int) ) ) {
+ kfree( x );
+ kfree( y );
+ return -EFAULT;
+ }
+ if ( copy_from_user( y, depth->y, count * sizeof(int) ) ) {
+ kfree( x );
+ kfree( y );
+ return -EFAULT;
+ }
+
+ for ( i = 0 ; i < count ; i++ ) {
+ BEGIN_RING( 7 );
+
+ OUT_RING( CCE_PACKET3( R128_CNTL_BITBLT_MULTI, 5 ) );
+ OUT_RING( R128_GMC_SRC_PITCH_OFFSET_CNTL
+ | R128_GMC_DST_PITCH_OFFSET_CNTL
+ | R128_GMC_BRUSH_NONE
+ | depth_bpp
+ | R128_GMC_SRC_DATATYPE_COLOR
+ | R128_ROP3_S
+ | R128_DP_SRC_SOURCE_MEMORY
+ | R128_GMC_CLR_CMP_CNTL_DIS
+ | R128_GMC_WR_MSK_DIS );
+
+ OUT_RING( dev_priv->depth_pitch_offset_c );
+ OUT_RING( dev_priv->span_pitch_offset_c );
+
+ OUT_RING( (x[i] << 16) | y[i] );
+ OUT_RING( (i << 16) | 0 );
+ OUT_RING( (1 << 16) | 1 );
+
+ ADVANCE_RING();
+ }
+
+ kfree( x );
+ kfree( y );
+
+ return 0;
+}
+
+
+/* ================================================================
+ * Polygon stipple
+ */
+
+static void r128_cce_dispatch_stipple( drm_device_t *dev, u32 *stipple )
+{
+ drm_r128_private_t *dev_priv = dev->dev_private;
+ int i;
+ RING_LOCALS;
+ DRM_DEBUG( "%s\n", __FUNCTION__ );
+
+ r128_update_ring_snapshot( dev_priv );
+
+ BEGIN_RING( 33 );
+
+ OUT_RING( CCE_PACKET0( R128_BRUSH_DATA0, 31 ) );
+ for ( i = 0 ; i < 32 ; i++ ) {
+ OUT_RING( stipple[i] );
+ }
+
+ ADVANCE_RING();
+}
+
+
+/* ================================================================
+ * IOCTL functions
*/
int r128_cce_clear( struct inode *inode, struct file *filp,
@@ -1172,3 +1570,61 @@ int r128_cce_blit( struct inode *inode, struct file *filp,
return r128_cce_dispatch_blit( dev, &blit );
}
+
+int r128_cce_depth( struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg )
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_depth_t depth;
+
+ if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) ||
+ dev->lock.pid != current->pid ) {
+ DRM_ERROR( "%s called without lock held\n", __FUNCTION__ );
+ return -EINVAL;
+ }
+
+ if ( copy_from_user( &depth, (drm_r128_depth_t *)arg,
+ sizeof(depth) ) )
+ return -EFAULT;
+
+ switch ( depth.func ) {
+ case R128_WRITE_SPAN:
+ return r128_cce_dispatch_write_span( dev, &depth );
+ case R128_WRITE_PIXELS:
+ return r128_cce_dispatch_write_pixels( dev, &depth );
+ case R128_READ_SPAN:
+ return r128_cce_dispatch_read_span( dev, &depth );
+ case R128_READ_PIXELS:
+ return r128_cce_dispatch_read_pixels( dev, &depth );
+ }
+
+ return -EINVAL;
+}
+
+int r128_cce_stipple( struct inode *inode, struct file *filp,
+ unsigned int cmd, unsigned long arg )
+{
+ drm_file_t *priv = filp->private_data;
+ drm_device_t *dev = priv->dev;
+ drm_r128_stipple_t stipple;
+ u32 mask[32];
+
+ if ( !_DRM_LOCK_IS_HELD( dev->lock.hw_lock->lock ) ||
+ dev->lock.pid != current->pid ) {
+ DRM_ERROR( "%s called without lock held\n", __FUNCTION__ );
+ return -EINVAL;
+ }
+
+ if ( copy_from_user( &stipple, (drm_r128_stipple_t *)arg,
+ sizeof(stipple) ) )
+ return -EFAULT;
+
+ if ( copy_from_user( &mask, stipple.mask,
+ 32 * sizeof(u32) ) )
+ return -EFAULT;
+
+ r128_cce_dispatch_stipple( dev, mask );
+
+ return 0;
+}
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c
index db671687f..0b89d0867 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c
+++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/xf86drmR128.c
@@ -96,22 +96,15 @@ int drmR128InitCCE( int fd, drmR128Init *info )
init.usec_timeout = info->usec_timeout;
init.fb_bpp = info->fb_bpp;
- init.depth_bpp = info->depth_bpp;
-
init.front_offset = info->front_offset;
init.front_pitch = info->front_pitch;
- init.front_x = info->front_x;
- init.front_y = info->front_y;
-
init.back_offset = info->back_offset;
init.back_pitch = info->back_pitch;
- init.back_x = info->back_x;
- init.back_y = info->back_y;
+ init.depth_bpp = info->depth_bpp;
init.depth_offset = info->depth_offset;
init.depth_pitch = info->depth_pitch;
- init.depth_x = info->depth_x;
- init.depth_y = info->depth_y;
+ init.span_offset = info->span_offset;
init.fb_offset = info->fb_offset;
init.mmio_offset = info->mmio_offset;
@@ -305,6 +298,97 @@ int drmR128TextureBlit( int fd, int index,
}
}
+int drmR128WriteDepthSpan( int fd, int n, int x, int y,
+ const unsigned int depth[],
+ const unsigned char mask[] )
+{
+ drm_r128_depth_t d;
+
+ d.func = R128_WRITE_SPAN;
+ d.n = n;
+ d.x = &x;
+ d.y = &y;
+ d.buffer = (unsigned int *)depth;
+ d.mask = (unsigned char *)mask;
+
+ if ( ioctl( fd, DRM_IOCTL_R128_DEPTH, &d ) < 0 ) {
+ return -errno;
+ } else {
+ return 0;
+ }
+}
+
+int drmR128WriteDepthPixels( int fd, int n,
+ const int x[], const int y[],
+ const unsigned int depth[],
+ const unsigned char mask[] )
+{
+ drm_r128_depth_t d;
+
+ d.func = R128_WRITE_PIXELS;
+ d.n = n;
+ d.x = (int *)x;
+ d.y = (int *)y;
+ d.buffer = (unsigned int *)depth;
+ d.mask = (unsigned char *)mask;
+
+ if ( ioctl( fd, DRM_IOCTL_R128_DEPTH, &d ) < 0 ) {
+ return -errno;
+ } else {
+ return 0;
+ }
+}
+
+int drmR128ReadDepthSpan( int fd, int n, int x, int y )
+{
+ drm_r128_depth_t d;
+
+ d.func = R128_READ_SPAN;
+ d.n = n;
+ d.x = &x;
+ d.y = &y;
+ d.buffer = NULL;
+ d.mask = NULL;
+
+ if ( ioctl( fd, DRM_IOCTL_R128_DEPTH, &d ) < 0 ) {
+ return -errno;
+ } else {
+ return 0;
+ }
+}
+
+int drmR128ReadDepthPixels( int fd, int n,
+ const int x[], const int y[] )
+{
+ drm_r128_depth_t d;
+
+ d.func = R128_READ_PIXELS;
+ d.n = n;
+ d.x = (int *)x;
+ d.y = (int *)y;
+ d.buffer = NULL;
+ d.mask = NULL;
+
+ if ( ioctl( fd, DRM_IOCTL_R128_DEPTH, &d ) < 0 ) {
+ return -errno;
+ } else {
+ return 0;
+ }
+}
+
+int drmR128PolygonStipple( int fd, unsigned int *mask )
+{
+ drm_r128_stipple_t stipple;
+
+ stipple.mask = mask;
+
+ if ( ioctl( fd, DRM_IOCTL_R128_STIPPLE, &stipple ) < 0 ) {
+ return -errno;
+ } else {
+ return 0;
+ }
+}
+
int drmR128SubmitPacket( int fd, void *buffer, int *count, int flags )
{
drm_r128_packet_t packet;
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
index 5d3834272..20691ccf2 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/shared/drm/kernel/drm.h
@@ -374,7 +374,9 @@ typedef struct drm_agp_info {
#define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x49, drm_r128_vertex_t)
#define DRM_IOCTL_R128_INDICES DRM_IOW( 0x4a, drm_r128_indices_t)
#define DRM_IOCTL_R128_BLIT DRM_IOW( 0x4b, drm_r128_blit_t)
-#define DRM_IOCTL_R128_PACKET DRM_IOWR(0x4c, drm_r128_packet_t)
+#define DRM_IOCTL_R128_DEPTH DRM_IOW( 0x4c, drm_r128_depth_t)
+#define DRM_IOCTL_R128_STIPPLE DRM_IOW( 0x4d, drm_r128_stipple_t)
+#define DRM_IOCTL_R128_PACKET DRM_IOWR(0x4e, drm_r128_packet_t)
/* SiS specific ioctls */
#define SIS_IOCTL_FB_ALLOC DRM_IOWR( 0x44, drm_sis_mem_t)
diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h
index 720cc57ca..da1ee67d1 100644
--- a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h
+++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h
@@ -50,12 +50,10 @@ typedef struct {
unsigned int fb_bpp;
unsigned int front_offset, front_pitch;
- unsigned int front_x, front_y;
unsigned int back_offset, back_pitch;
- unsigned int back_x, back_y;
unsigned int depth_bpp;
unsigned int depth_offset, depth_pitch;
- unsigned int depth_x, depth_y;
+ unsigned int span_offset;
unsigned int fb_offset;
unsigned int mmio_offset;
@@ -65,13 +63,6 @@ typedef struct {
unsigned int agp_textures_offset;
} drmR128Init;
-typedef struct {
- int index;
- unsigned short x, y;
- unsigned short width, height;
- int padding;
-} drmR128BlitRectRec, *drmR128BlitRectPtr;
-
extern int drmR128InitCCE( int fd, drmR128Init *info );
extern int drmR128CleanupCCE( int fd );
@@ -97,6 +88,19 @@ extern int drmR128TextureBlit( int fd, int index,
int offset, int pitch, int format,
int x, int y, int width, int height );
+extern int drmR128WriteDepthSpan( int fd, int n, int x, int y,
+ const unsigned int depth[],
+ const unsigned char mask[] );
+extern int drmR128WriteDepthPixels( int fd, int n,
+ const int x[], const int y[],
+ const unsigned int depth[],
+ const unsigned char mask[] );
+extern int drmR128ReadDepthSpan( int fd, int n, int x, int y );
+extern int drmR128ReadDepthPixels( int fd, int n,
+ const int x[], const int y[] );
+
+extern int drmR128PolygonStipple( int fd, unsigned int *mask );
+
extern int drmR128SubmitPacket( int fd, void *buffer,
int *count, int flags );