Index: ati_draw.c =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_draw.c,v retrieving revision 1.33 diff -u -r1.33 ati_draw.c --- ati_draw.c 21 Feb 2005 03:44:10 -0000 1.33 +++ ati_draw.c 21 Feb 2005 05:55:35 -0000 @@ -1,5 +1,5 @@ /* - * $Id: ati_draw.c,v 1.33 2005/02/21 03:44:10 anholt Exp $ + * $Id: ati_draw.c,v 1.32 2005/01/27 05:25:57 anholt Exp $ * * Copyright © 2003 Eric Anholt * @@ -21,7 +21,7 @@ * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR * PERFORMANCE OF THIS SOFTWARE. */ -/* $Header: /cvs/xserver/xserver/hw/kdrive/ati/ati_draw.c,v 1.33 2005/02/21 03:44:10 anholt Exp $ */ +/* $Header: /cvs/xserver/xserver/hw/kdrive/ati/ati_draw.c,v 1.32 2005/01/27 05:25:57 anholt Exp $ */ #ifdef HAVE_CONFIG_H #include @@ -559,18 +559,14 @@ KdScreenPriv(pScreen); ATIScreenInfo(pScreenPriv); ATICardInfo(pScreenPriv); - int width, height, bpp, i, dwords; + int width, height, bpp, i, dwords, blit_row_dwords; int dst_pitch, dst_offset; CARD32 dst_pitch_offset, datatype; Bool success; RING_LOCALS; - ENTER_DRAW (pDst); + ENTER_DRAW(pDst); - LEAVE_DRAW (pDst); - /* XXX: Hostdata uploads aren't working yet. */ - return FALSE; - dst_offset = ((CARD8 *)pDst->devPrivate.ptr - pScreenPriv->screen->memory_base); dst_pitch = pDst->devKind; @@ -581,24 +577,19 @@ success = ATIGetDatatypeBpp(bpp, &datatype); if (bpp == 24) { - is_24bpp = TRUE; + width *= 3; bpp = 8; - } else - is_24bpp = FALSE; + return FALSE; /* XXX? */ + } if (!ATIGetOffsetPitch(atis, bpp, &dst_pitch_offset, dst_offset, dst_pitch)) return FALSE; - if (src_pitch != (width * bpp / 8)) - return FALSE; - /* No PACKET3 packets when in PIO mode. */ if (atis->using_pio) return FALSE; - dwords = (width * height * (bpp / 8) + 3) / 4; - /* Flush pixel cache so nothing being written to the destination * previously gets mixed up with the hostdata blit. */ @@ -617,7 +608,37 @@ END_DMA(); } - BEGIN_DMA(8); + /* Munge width to align it to a 4-byte boundary. Makes uploading much + * easier, at the expense of us reading up to 3 bytes beyond the end of + * the source pixmap. + */ + switch (bpp) { + case 8: + width = (width + 3) & ~3; + blit_row_dwords = width / 4; + break; + case 16: + width = (width + 1) & ~1; + blit_row_dwords = width / 2; + break; + case 32: + blit_row_dwords = width; + break; + default: + ATI_FALLBACK(("unsupported bpp %d\n", bpp)); + } + + /* According to the DRM source, width must be a minimum of 8 dwords. + */ + /*if (blit_row_dwords < 8) + blit_row_dwords = 8;*/ + + dwords = blit_row_dwords * height; + + ErrorF("Uploading %d dwords, %d/row, tweaked w/h %d/%d\n", dwords, + blit_row_dwords, width, height); /* XXX */ + + BEGIN_DMA(8 + dwords); OUT_RING(DMA_PACKET3(ATI_CCE_PACKET3_HOSTDATA_BLT, 7 + dwords)); OUT_RING(ATI_GMC_DST_PITCH_OFFSET_CNTL | ATI_GMC_BRUSH_NONE | @@ -634,13 +655,19 @@ OUT_RING((0 << 16) | 0); OUT_RING((height << 16) | width); OUT_RING(dwords); - END_DMA(); - for (i = 0; i < dwords; i++) { - BEGIN_DMA(1); - OUT_RING(((CARD32 *)src)[i]); - END_DMA(); + for (i = 0; i < height; i++) { + int x_dword; + + /* XXX: This'll read beyond the end of the pixmap in < 32bpp, + * odd-width cases. + */ + for (x_dword = 0; x_dword < blit_row_dwords; x_dword++) { + OUT_RING(((CARD32 *)src)[x_dword]); + } + src += src_pitch; } + END_DMA(); if (atic->is_radeon) { BEGIN_DMA(4); @@ -657,8 +684,9 @@ } KdMarkSync(pScreen); + KdCheckSync(pScreen); /* XXX */ - ErrorF("hostdata upload %d,%d %dbpp\n", width, height, bpp); + LEAVE_DRAW(pDst); return TRUE; } Index: ati_draw.h =================================================================== RCS file: /cvs/xserver/xserver/hw/kdrive/ati/ati_draw.h,v retrieving revision 1.9 diff -u -r1.9 ati_draw.h --- ati_draw.h 21 Feb 2005 03:44:10 -0000 1.9 +++ ati_draw.h 21 Feb 2005 03:47:41 -0000 @@ -63,8 +63,8 @@ void RadeonSwitchTo3D(ATIScreenInfo *atis); void ATIWaitIdle(ATIScreenInfo *atis); -#define ATI_TRACE_FALL 0 -#define ATI_TRACE_DRAW 0 +#define ATI_TRACE_FALL 1 +#define ATI_TRACE_DRAW 1 #if ATI_TRACE_FALL #define ATI_FALLBACK(x) \