diff options
author | gareth <gareth> | 2000-06-12 15:46:30 +0000 |
---|---|---|
committer | gareth <gareth> | 2000-06-12 15:46:30 +0000 |
commit | 81a3d784f8ce3800cb6eca1a6a61df6397020f74 (patch) | |
tree | 977e75b6d1c00837fb93e58ec2c008f3599ac9ef | |
parent | c19b18f45c57ac421f36322223a5ac31bce6697c (diff) |
Merging the ati-4-1-0 branch onto the trunk.
28 files changed, 1099 insertions, 1692 deletions
diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_cce.c b/xc/lib/GL/mesa/src/drv/r128/r128_cce.c index e949dd37c..a89d7dc84 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_cce.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_cce.c @@ -28,7 +28,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: - * Kevin E. Martin <kevin@precisioninsight.com> + * Gareth Hughes <gareth@precisioninsight.com> * */ @@ -37,353 +37,297 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_xmesa.h" #include "r128_context.h" #include "r128_lock.h" +#include "r128_state.h" #include "r128_reg.h" #include "r128_cce.h" -#if USE_USER_SPACE_RING - -#define USE_IOCTLS 0 -#define DO_SECURITY_CHECK 1 #define R128_TIMEOUT 2000000 -#if DEBUG -static void r128RingStatus(r128ScreenPtr pScrn) +typedef drmBufPtr (*r128_get_buffer_func)( r128ContextPtr r128ctx ); + +static r128_get_buffer_func r128GetBufferLocked; +r128_fire_vertices_func r128FireVerticesLocked; + + +static void r128RingStatus( r128ContextPtr r128ctx ) { - unsigned char *R128MMIO = pScrn->mmio; - - R128_DEBUG(("GUI_STAT = 0x%08x\n", - (unsigned int)INREG(R128_GUI_STAT))); - R128_DEBUG(("PM4_STAT = 0x%08x\n", - (unsigned int)INREG(R128_PM4_STAT))); - R128_DEBUG(("PM4_BUFFER_DL_WPTR = 0x%08x\n", - (unsigned int)INREG(R128_PM4_BUFFER_DL_WPTR))); - R128_DEBUG(("PM4_BUFFER_DL_RPTR = 0x%08x\n", - (unsigned int)INREG(R128_PM4_BUFFER_DL_RPTR))); - R128_DEBUG(("ringWrite = 0x%08x\n", pScrn->SAREA->ringWrite)); - R128_DEBUG(("*ringReadPtr = 0x%08x\n", *pScrn->ringReadPtr)); + r128ScreenPtr r128scrn = r128ctx->r128Screen; + unsigned char *R128MMIO = r128scrn->mmio; + + fprintf( stderr, "GUI_STAT = 0x%08x\n", + (unsigned int) INREG( R128_GUI_STAT ) ); + fprintf( stderr, "PM4_STAT = 0x%08x\n", + (unsigned int) INREG( R128_PM4_STAT ) ); + fprintf( stderr, "PM4_BUFFER_DL_WPTR = 0x%08x\n", + (unsigned int) INREG( R128_PM4_BUFFER_DL_WPTR ) ); + fprintf( stderr, "PM4_BUFFER_DL_RPTR = 0x%08x\n", + (unsigned int) INREG( R128_PM4_BUFFER_DL_RPTR ) ); + fprintf( stderr, "ringWrite = 0x%08x\n", + r128scrn->SAREA->ringWrite ); + fprintf( stderr, "*ringReadPtr = 0x%08x\n", + *r128scrn->ringReadPtr ); } -#endif -/* FIXME: Requires access to secure registers */ -static int INPLL(r128ScreenPtr pScrn, int addr) + +/* Get a new VB from the pool of vertex buffers in AGP space. + */ +static drmBufPtr r128_get_buffer_locked( r128ContextPtr r128ctx ) { - unsigned char *R128MMIO = pScrn->mmio; + int fd = r128ctx->r128Screen->driScreen->fd; + int num; + int index = 0; + int size = 0; + int to = 0; + drmBufPtr buf = NULL; + + while ( !buf && ( to++ < r128ctx->CCEtimeout ) ) { + num = drmR128GetVertexBuffers( fd, 1, &index, &size ); + + if ( num > 0 ) { + buf = &r128ctx->r128Screen->vbBufs->list[index]; + buf->used = 0; + return buf; + } + } + + if ( !buf ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not get new VB... exiting\n" ); + exit( -1 ); + } + + return buf; +} - OUTREG8(R128_CLOCK_CNTL_INDEX, addr & 0x1f); - return INREG(R128_CLOCK_CNTL_DATA); +static void r128_fire_vertices_locked( r128ContextPtr r128ctx ) +{ + int vertsize = r128ctx->vertsize; + int format = r128ctx->vc_format; + int index = r128ctx->vert_buf->idx; + int offset = r128ctx->r128Screen->vbOffset + + index * r128ctx->r128Screen->vbBufSize; + int size = r128ctx->vert_buf->used / (vertsize * sizeof(GLuint)); + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + CARD32 prim; + + prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST; + + /* Send the vertex buffer to the hardware */ + BEGIN_CLIP_LOOP( r128ctx ); + { + R128CCE3( R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3 ); + R128CCE( offset ); + R128CCE( size ); + R128CCE( format ); + R128CCE( prim | R128_CCE_VC_CNTL_PRIM_WALK_LIST | + (size << R128_CCE_VC_CNTL_NUM_SHIFT) ); + + R128CCE_SUBMIT_PACKET(); + } + END_CLIP_LOOP( r128ctx ); + + /* Tell the kernel to release the vertex buffer */ + do { + ret = drmR128FlushVertexBuffers( fd, 1, &index, &size, 0 ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not flush VB... exiting\n" ); + exit( -1 ); + } + + r128ctx->vert_buf = NULL; } -/* FIXME: Requires access to secure registers */ -static void r128EngineFlush(r128ScreenPtr pScrn) +static drmBufPtr r128_get_ring_locked( r128ContextPtr r128ctx ) { - unsigned char *R128MMIO = pScrn->mmio; - int i; + r128ScreenPtr r128scrn = r128ctx->r128Screen; + drmBufPtr buf = NULL; - OUTREGP(R128_PC_NGUI_CTLSTAT, R128_PC_FLUSH_ALL, ~R128_PC_FLUSH_ALL); - for (i = 0; i < R128_TIMEOUT; i++) { - if (!(INREG(R128_PC_NGUI_CTLSTAT) & R128_PC_BUSY)) break; - } + buf = (drmBufPtr) malloc( sizeof(*buf) ); + + buf->idx = -666; + buf->total = r128scrn->vbBufSize; + buf->used = 0; + buf->address = (drmAddress *) malloc( r128scrn->vbBufSize ); + + return buf; } -/* FIXME: Requires access to secure registers */ -static void r128EngineReset(r128ScreenPtr pScrn) +static void r128_fire_ring_locked( r128ContextPtr r128ctx ) { -#if USE_IOCTLS -#if DEBUG - r128RingStatus(pScrn); -#endif - - (void)drmR128EngineReset(pScrn->driScreen->fd); -#else - unsigned char *R128MMIO = pScrn->mmio; - CARD32 clock_cntl_index; - CARD32 mclk_cntl; - CARD32 gen_reset_cntl; - -#if DEBUG - r128RingStatus(pScrn); -#endif - - r128EngineFlush(pScrn); - - clock_cntl_index = INREG(R128_CLOCK_CNTL_INDEX); - mclk_cntl = INPLL(pScrn, R128_MCLK_CNTL); - - OUTPLL(R128_MCLK_CNTL, mclk_cntl | R128_FORCE_GCP | R128_FORCE_PIPE3D_CPP); - - gen_reset_cntl = INREG(R128_GEN_RESET_CNTL); - - OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl | R128_SOFT_RESET_GUI); - INREG(R128_GEN_RESET_CNTL); - OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl & ~R128_SOFT_RESET_GUI); - INREG(R128_GEN_RESET_CNTL); - - OUTPLL(R128_MCLK_CNTL, mclk_cntl); - OUTREG(R128_CLOCK_CNTL_INDEX, clock_cntl_index); - OUTREG(R128_GEN_RESET_CNTL, gen_reset_cntl); - - /* Reset the ring buffer status */ - if (R128CCE_USE_RING_BUFFER(pScrn->CCEMode)) { - OUTREG(R128_PM4_BUFFER_DL_WPTR, 0); - OUTREG(R128_PM4_BUFFER_DL_RPTR, 0); - pScrn->SAREA->ringWrite = 0; - *pScrn->ringReadPtr = 0; - } -#endif - fprintf(stderr, "Error: Rage 128 timed out... exiting\n"); - exit(-1); -} + int vertsize = r128ctx->vertsize; + int format = r128ctx->vc_format; + int size = r128ctx->vert_buf->used / (vertsize * sizeof(GLuint)); + drmBufPtr buf = r128ctx->vert_buf; + CARD32 prim; -#define r128CCEWaitForFifo(pScrn, entries) \ -do { \ - if (pScrn->CCEFifoSlots < entries) \ - r128CCEWaitForFifoFunction(pScrn, entries); \ - pScrn->CCEFifoSlots -= entries; \ -} while (0) + prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST; -/* Wait for at least `entries' slots are free. The actual number of - slots available is stored in info->CCEFifoSize. */ -static void r128CCEWaitForFifoFunction(r128ScreenPtr pScrn, int entries) -{ - unsigned char *R128MMIO = pScrn->mmio; - int i; + /* Send the vertex buffer to the hardware */ + BEGIN_CLIP_LOOP( r128ctx ); + { + R128CCE3( R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 3 ); + R128CCE( format ); + R128CCE( prim | R128_CCE_VC_CNTL_PRIM_WALK_RING | + (size << R128_CCE_VC_CNTL_NUM_SHIFT) ); - for (;;) { - for (i = 0; i < R128_TIMEOUT; i++) { - pScrn->CCEFifoSlots = INREG(R128_PM4_STAT) & R128_PM4_FIFOCNT_MASK; - if (pScrn->CCEFifoSlots >= entries) return; - } - R128_DEBUG(("Reseting Engine: PM4_STAT = 0x%08x\n", - (unsigned int)INREG(R128_PM4_STAT))); - r128EngineReset(pScrn); - } + memcpy( &r128ctx->CCEbuf[r128ctx->CCEcount], buf->address, buf->used ); + r128ctx->CCEcount += (buf->used >> 2); + + R128CCE_SUBMIT_PACKET(); + } + END_CLIP_LOOP( r128ctx ); + + free( buf->address ); + free( buf ); + + r128ctx->vert_buf = NULL; } -/* Wait until the CCE is completely idle: the FIFO has drained and the - CCE is idle. */ -void r128CCEWaitForIdle(r128ScreenPtr pScrn) + +void r128FlushVerticesLocked( r128ContextPtr r128ctx ) { -#if USE_IOCTLS - if (drmR128WaitForIdle(pScrn->driScreen->fd) < 0) { - fprintf(stderr, "Error: Rage 128 timed out... exiting\n"); - exit(-1); - } -#else - unsigned char *R128MMIO = pScrn->mmio; - int i; - - if (R128CCE_USE_RING_BUFFER(pScrn->CCEMode)) { - OUTREGP(R128_PM4_BUFFER_DL_WPTR, - R128_PM4_BUFFER_DL_DONE, ~R128_PM4_BUFFER_DL_DONE); - - for (;;) { - for (i = 0; i < R128_TIMEOUT; i++) { - if (*pScrn->ringReadPtr == pScrn->SAREA->ringWrite) { - int pm4stat = INREG(R128_PM4_STAT); - if ((pm4stat & R128_PM4_FIFOCNT_MASK) == pScrn->CCEFifoSize - && !(pm4stat & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) - return; - } - } - R128_DEBUG(("Reseting Engine: PM4_STAT = 0x%08x\n", - (unsigned int)INREG(R128_PM4_STAT))); - r128EngineReset(pScrn); - } - } else { - r128CCEWaitForFifoFunction(pScrn, pScrn->CCEFifoSize); - - for (;;) { - for (i = 0; i < R128_TIMEOUT; i++) { - if (!(INREG(R128_PM4_STAT) - & (R128_PM4_BUSY | R128_PM4_GUI_ACTIVE))) { - r128EngineFlush(pScrn); - return; - } - } - R128_DEBUG(("Reseting Engine: PM4_STAT = 0x%08x\n", - (unsigned int)INREG(R128_PM4_STAT))); - r128EngineReset(pScrn); - } + if ( r128ctx->vert_buf && r128ctx->vert_buf->used ) { + r128FireVerticesLocked( r128ctx ); } -#endif } -/* Send a packet to the CCE via the PIO registers */ -static void r128CCESubmitPacketPIO(r128ContextPtr r128ctx, - CARD32 *buf, int count) +CARD32 *r128AllocVertexDwords( r128ContextPtr r128ctx, int dwords ) { - unsigned char *R128MMIO = r128ctx->r128Screen->mmio; -#if DO_SECURITY_CHECK - CARD32 tmp = 0; - int psize = 0; - int writing = 1; - int addr = R128_PM4_FIFO_DATA_EVEN; -#endif - -#if DO_SECURITY_CHECK - while (count > 0) { - tmp = *buf++; - if (!psize) { - writing = 1; - - if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) { - if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) { - if ((tmp & R128_CCE_PACKET0_REG_MASK) != - (R128_PM4_VC_FPU_SETUP >> 2)) { - writing = 0; - } - } - psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; - } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) { - if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) { - if ((tmp & R128_CCE_PACKET1_REG0_MASK) != - (R128_PM4_VC_FPU_SETUP >> 2)) { - writing = 0; - } - } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <= - (0x1004 << 9)) { - if ((tmp & R128_CCE_PACKET1_REG1_MASK) != - (R128_PM4_VC_FPU_SETUP << 9)) { - writing = 0; - } - } - psize = 3; - } else { - psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; - } - } - psize--; + int bytes = dwords * 4; + CARD32 *head; - if (writing) { - r128CCEWaitForFifo(r128ctx->r128Screen, 1); - OUTREG(addr, tmp); - addr ^= 0x0004; + if ( !r128ctx->vert_buf ) { + LOCK_HARDWARE( r128ctx ); + + if ( r128ctx->first_elt != r128ctx->next_elt ) { + r128FlushEltsLocked( r128ctx ); } + r128ctx->vert_buf = r128GetBufferLocked( r128ctx ); - count--; - } + UNLOCK_HARDWARE( r128ctx ); + } else if ( r128ctx->vert_buf->used + bytes > r128ctx->vert_buf->total ) { + LOCK_HARDWARE( r128ctx ); - if (addr == R128_PM4_FIFO_DATA_ODD) { - r128CCEWaitForFifo(r128ctx->r128Screen, 1); - OUTREG(addr, R128_CCE_PACKET2); - } -#else - while (count > 1) { - r128CCEWaitForFifo(r128ctx->r128Screen, 2); - OUTREG(R128_PM4_FIFO_DATA_EVEN, *buf++); - OUTREG(R128_PM4_FIFO_DATA_ODD, *buf++); - count -= 2; - } + r128FlushVerticesLocked( r128ctx ); + r128ctx->vert_buf = r128GetBufferLocked( r128ctx ); - if (count) { - r128CCEWaitForFifo(r128ctx->r128Screen, 2); - OUTREG(R128_PM4_FIFO_DATA_EVEN, *buf); - OUTREG(R128_PM4_FIFO_DATA_ODD, R128_CCE_PACKET2); + UNLOCK_HARDWARE( r128ctx ); } -#endif + + head = (CARD32 *)((char *)r128ctx->vert_buf->address + + r128ctx->vert_buf->used); + + r128ctx->vert_buf->used += bytes; + return head; } -/* Send a packet to the CCE via the ring */ -static void r128CCESubmitPacketRing(r128ContextPtr r128ctx, - CARD32 *buf, int count) -{ - r128ScreenPtr r128scrn = r128ctx->r128Screen; - unsigned char *R128MMIO = r128ctx->r128Screen->mmio; - int ringWrite = r128scrn->SAREA->ringWrite; - int *ringWritePtr = r128scrn->ringStartPtr + ringWrite; - int timeout; -#if DO_SECURITY_CHECK - CARD32 tmp = 0; - int psize = 0; - int writing = 1; -#endif - - if (count > r128scrn->ringEntries) { - /* FIXME */ - return; - } - while (count > 0) { -#if DO_SECURITY_CHECK - tmp = *buf++; - if (!psize) { - writing = 1; - - if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET0) { - if ((tmp & R128_CCE_PACKET0_REG_MASK) <= (0x1004 >> 2)) { - if ((tmp & R128_CCE_PACKET0_REG_MASK) != - (R128_PM4_VC_FPU_SETUP >> 2)) { - writing = 0; - } - } - psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; - } else if ((tmp & R128_CCE_PACKET_MASK) == R128_CCE_PACKET1) { - if ((tmp & R128_CCE_PACKET1_REG0_MASK) <= (0x1004 >> 2)) { - if ((tmp & R128_CCE_PACKET1_REG0_MASK) != - (R128_PM4_VC_FPU_SETUP >> 2)) { - writing = 0; - } - } else if ((tmp & R128_CCE_PACKET1_REG1_MASK) <= - (0x1004 << 9)) { - if ((tmp & R128_CCE_PACKET1_REG1_MASK) != - (R128_PM4_VC_FPU_SETUP << 9)) { - writing = 0; - } - } - psize = 3; - } else { - psize = ((tmp & R128_CCE_PACKET_COUNT_MASK) >> 16) + 2; - } - } - psize--; +/* ================================================================ */ - if (writing) { - ringWrite++; - *ringWritePtr++ = tmp; - } -#else - ringWrite++; - *ringWritePtr++ = *buf++; -#endif - if (ringWrite >= r128scrn->ringEntries) { - ringWrite = 0; - ringWritePtr = r128scrn->ringStartPtr; - } - timeout = 0; - while (ringWrite == *r128scrn->ringReadPtr) { - (void)INREG(R128_PM4_BUFFER_DL_RPTR); - if (timeout++ >= R128_TIMEOUT) r128EngineReset(r128scrn); - } - count--; - } +void r128GetEltBufLocked( r128ContextPtr r128ctx ) +{ + r128ctx->elt_buf = r128GetBufferLocked( r128ctx ); +} - if (ringWrite < 32) { - memcpy(r128scrn->ringEndPtr, - r128scrn->ringStartPtr, - ringWrite * sizeof(int)); - } +void r128FireEltsLocked( r128ContextPtr r128ctx, + GLuint num_elts, GLuint discard ) +{ + int vertsize = r128ctx->vertsize; + int format = r128ctx->vc_format; + int index = r128ctx->vert_buf->idx; + int offset = r128ctx->r128Screen->vbOffset + + index * r128ctx->r128Screen->vbBufSize; + int size = r128ctx->vert_buf->used / (vertsize * sizeof(GLuint)); + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + CARD32 prim; + + fprintf( stderr, "Error: elt buffers not supported at this time...\n" ); + return; + + prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST; + + /* Send the vertex buffer to the hardware */ + BEGIN_CLIP_LOOP( r128ctx ); + { + R128CCE3( R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3 ); + R128CCE( offset ); + R128CCE( size ); + R128CCE( format ); + R128CCE( prim | R128_CCE_VC_CNTL_PRIM_WALK_IND | + (size << R128_CCE_VC_CNTL_NUM_SHIFT) ); + + R128CCE_SUBMIT_PACKET(); + } + END_CLIP_LOOP( r128ctx ); + + if ( discard ) { + /* Tell the kernel to release the vertex buffer */ + do { + ret = drmR128FlushVertexBuffers( fd, 1, &index, &size, 0 ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not flush VB... exiting\n" ); + exit( -1 ); + } + } + + r128ctx->vert_buf = NULL; +} - r128scrn->SAREA->ringWrite = ringWrite; - OUTREG(R128_PM4_BUFFER_DL_WPTR, ringWrite); +void r128FlushEltsLocked( r128ContextPtr r128ctx ) +{ + if ( r128ctx->first_elt != r128ctx->next_elt ) { + r128FireEltsLocked( r128ctx, + (GLuint)r128ctx->next_elt - + (GLuint)r128ctx->first_elt, + 0 ); + r128ctx->first_elt = r128ctx->next_elt; + } } -void r128CCESubmitPackets(r128ContextPtr r128ctx, CARD32 *buf, int count) +void r128ReleaseBufLocked( r128ContextPtr r128ctx, drmBufPtr buffer ) { -#if USE_IOCTLS - if (drmR128SubmitPackets(r128ctx->r128Screen->driScreen->fd, - r128ctx->CCEbuf, r128ctx->CCEcount, - 0) < 0) { - r128EngineReset(r128ctx->r128Screen); - fprintf(stderr, "Error: Illegal CCE packet... exiting\n"); - exit(-1); - } -#else - if (R128CCE_USE_RING_BUFFER(r128ctx->r128Screen->CCEMode)) - r128CCESubmitPacketRing(r128ctx, buf, count); - else - r128CCESubmitPacketPIO(r128ctx, buf, count); -#endif + int index; + int size; + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + + if ( !buffer ) return; + + index = buffer->idx; + size = buffer->used = 0; + + /* Tell the kernel to release the vertex buffer */ + do { + ret = drmR128FlushVertexBuffers( fd, 1, &index, &size, 0 ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not release VB... exiting\n" ); + exit( -1 ); + } } -#endif + +void r128InitVertexBuffers( r128ScreenPtr r128scrn ) +{ + if ( !r128scrn->IsPCI ) { + r128GetBufferLocked = r128_get_buffer_locked; + r128FireVerticesLocked = r128_fire_vertices_locked; + } else { + r128GetBufferLocked = r128_get_ring_locked; + r128FireVerticesLocked = r128_fire_ring_locked; + } +} diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_cce.h b/xc/lib/GL/mesa/src/drv/r128/r128_cce.h index 162686cb7..768151971 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_cce.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_cce.h @@ -29,6 +29,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* * Authors: * Kevin E. Martin <kevin@precisioninsight.com> + * Gareth Hughes <gareth@precisioninsight.com> * */ @@ -42,88 +43,28 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "xf86drmR128.h" +#define R128_DEFAULT_TOTAL_CCE_TIMEOUT 1000000 /* usecs */ + typedef union { float f; int i; } floatTOint; -#define R128_DEFAULT_TOTAL_CCE_TIMEOUT 1000000 /* usecs */ - /* Insert an integer value into the CCE ring buffer. */ -#define R128CCE(v) \ - do { \ - r128ctx->CCEbuf[r128ctx->CCEcount] = (v); \ - r128ctx->CCEcount++; \ - } while (0) +#define R128CCE(v) \ +do { \ + r128ctx->CCEbuf[r128ctx->CCEcount] = (v); \ + r128ctx->CCEcount++; \ +} while (0) /* Insert an floating point value into the CCE ring buffer. */ -#define R128CCEF(v) \ - do { \ - floatTOint fTi; \ - fTi.f = (v); \ - r128ctx->CCEbuf[r128ctx->CCEcount] = fTi.i; \ - r128ctx->CCEcount++; \ - } while (0) - -#if USE_USER_SPACE_RING - -#define R128CCE_SUBMIT_PACKETS() \ - do { \ - r128CCESubmitPackets(r128ctx, r128ctx->CCEbuf, r128ctx->CCEcount); \ - r128ctx->CCEcount = 0; \ - } while (0) - -#define R128CCE_WAIT_FOR_IDLE(r128ctx) \ - r128CCEWaitForIdle(r128ctx->r128Screen) - -#else /* if !USE_USER_SPACE_RING */ - -#define R128CCE_SUBMIT_PACKETS() \ - do { \ - CARD32 *_buf; \ - int _c = r128ctx->CCEcount; \ - int _fd = r128ctx->r128Screen->driScreen->fd; \ - int _to = 0; \ - int _ret; \ - \ - do { \ - _buf = r128ctx->CCEbuf + (r128ctx->CCEcount - _c); \ - _ret = drmR128SubmitPackets(_fd, _buf, &_c, 0); \ - } while (_ret < 0 && _ret == -EBUSY && _to++ < r128ctx->CCEtimeout); \ - if (_ret < 0) { \ - (void)drmR128EngineReset(_fd); \ - fprintf(stderr, "Error: Could not submit packet... exiting\n"); \ - exit(-1); \ - } \ - r128ctx->CCEcount = 0; \ - } while (0) - -#define R128CCE_WAIT_FOR_IDLE(r128ctx) \ - do { \ - int _fd = r128ctx->r128Screen->driScreen->fd; \ - int _to = 0; \ - int _ret; \ - \ - (void)drmR128EngineFlush(_fd); \ - do { \ - _ret = drmR128CCEWaitForIdle(_fd); \ - } while (_ret < 0 && _ret == -EBUSY && _to++ < r128ctx->CCEtimeout); \ - if (_ret < 0) { \ - (void)drmR128EngineReset(_fd); \ - fprintf(stderr, "Error: Rage 128 timed out... exiting\n"); \ - exit(-1); \ - } \ - } while (0) - -#endif - -#define R128CCE_WAIT_FOR_IDLE_LOCK(r128ctx) \ - do { \ - LOCK_HARDWARE(r128ctx); \ - R128CCE_WAIT_FOR_IDLE(r128ctx); \ - UNLOCK_HARDWARE(r128ctx); \ - } while (0) - +#define R128CCEF(v) \ +do { \ + floatTOint fTi; \ + fTi.f = (v); \ + r128ctx->CCEbuf[r128ctx->CCEcount] = fTi.i; \ + r128ctx->CCEcount++; \ +} while (0) /* Insert a type-[0123] packet header into the ring buffer */ #define R128CCE0(p,r,n) R128CCE((p) | ((n) << 16) | ((r) >> 2)) @@ -131,12 +72,89 @@ typedef union { #define R128CCE2(p) R128CCE((p)) #define R128CCE3(p,n) R128CCE((p) | ((n) << 16)) - -#if USE_USER_SPACE_RING -extern void r128CCEWaitForIdle(r128ScreenPtr pScrn); -extern void r128CCESubmitPackets(r128ContextPtr r128ctx, - CARD32 *buf, int count); -#endif +#define R128CCE_SUBMIT_PACKET() \ +do { \ + r128SubmitPacketLocked( r128ctx, r128ctx->CCEbuf, r128ctx->CCEcount ); \ + r128ctx->CCEcount = 0; \ +} while (0) + +static __inline void r128SubmitPacketLocked( r128ContextPtr r128ctx, + CARD32 *buf, GLuint count ) +{ + CARD32 *b; + int c = count; + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + + do { + b = buf + (count - c); + ret = drmR128SubmitPacket( fd, b, &c, 0 ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Could not submit packet... exiting\n" ); + exit( -1 ); + } +} + +static __inline void r128WaitForIdleLocked( r128ContextPtr r128ctx ) +{ + int fd = r128ctx->r128Screen->driScreen->fd; + int to = 0; + int ret; + + drmR128EngineFlush( fd ); + + do { + ret = drmR128WaitForIdle( fd ); + } while ( ( ret == -EBUSY ) && ( to++ < r128ctx->CCEtimeout ) ); + + if ( ret < 0 ) { + drmR128EngineReset( fd ); + fprintf( stderr, "Error: Rage 128 timed out... exiting\n" ); + exit( -1 ); + } +} + +#define r128WaitForIdle( r128ctx ) \ +do { \ + LOCK_HARDWARE( r128ctx ); \ + r128WaitForIdleLocked( r128ctx ); \ + UNLOCK_HARDWARE( r128ctx ); \ +} while (0) + + +extern CARD32 *r128AllocVertexDwords( r128ContextPtr r128ctx, int dwords ); +extern void r128FlushVerticesLocked( r128ContextPtr r128ctx ); + +typedef void (*r128_fire_vertices_func)( r128ContextPtr r128ctx ); +extern r128_fire_vertices_func r128FireVerticesLocked; + +#define r128FlushVertices( r128ctx ) \ +do { \ + LOCK_HARDWARE( r128ctx ); \ + r128FlushVerticesLocked( r128ctx ); \ + UNLOCK_HARDWARE( r128ctx ); \ +} while (0) + + +extern void r128GetEltBufLocked( r128ContextPtr r128ctx ); +extern void r128FlushEltsLocked( r128ContextPtr r128ctx ); +extern void r128FireEltsLocked( r128ContextPtr r128ctx, + GLuint num_elts, GLuint discard ); +extern void r128ReleaseBufLocked( r128ContextPtr r128ctx, drmBufPtr buffer ); + +#define r128FlushElts( r128ctx ) \ +do { \ + LOCK_HARDWARE( r128ctx ); \ + r128FlushEltsLocked( r128ctx ); \ + UNLOCK_HARDWARE( r128ctx ); \ +} while (0) + + +extern void r128InitVertexBuffers( r128ScreenPtr r128scrn ); #endif #endif /* _R128_CCE_H_ */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_ccevb.h b/xc/lib/GL/mesa/src/drv/r128/r128_ccevb.h deleted file mode 100644 index 2084b8672..000000000 --- a/xc/lib/GL/mesa/src/drv/r128/r128_ccevb.h +++ /dev/null @@ -1,224 +0,0 @@ -/* $XFree86$ */ -/************************************************************************** - -Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. -All Rights Reserved. - -Permission is hereby granted, free of charge, to any person obtaining a -copy of this software and associated documentation files (the "Software"), -to deal in the Software without restriction, including without limitation -on the rights to use, copy, modify, merge, publish, distribute, sub -license, and/or sell copies of the Software, and to permit persons to whom -the Software is furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice (including the next -paragraph) shall be included in all copies or substantial portions of the -Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL -ATI, PRECISION INSIGHT AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM, -DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR -OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE -USE OR OTHER DEALINGS IN THE SOFTWARE. - -**************************************************************************/ - -/* - * Authors: - * Kevin E. Martin <kevin@precisioninsight.com> - * - */ - -#ifndef _R128_CCEVB_H_ -#define _R128_CCEVB_H_ - -#ifdef GLX_DIRECT_RENDERING - -#include "xf86drmR128.h" - -typedef struct { - CARD32 *buf; /* Pointer to current VB */ - int index; /* Index of current VB */ - int start; /* in bytes from the beginning of the VB map */ - int size; /* in vertices */ - int count; /* in vertices */ - drmR128PrimType prim; /* Primitive type for vertices in VB */ - int done; /* VB has been sent to ring */ -} r128CCEVertBuf, *r128CCEVertBufPtr; - - - -/* Flush the CPU's write-combining cache */ -/* FIXME: This code is both processor and compiler specific */ -#define R128_FLUSH_WC_MEMORY() \ - do { \ - int xchangeDummy; \ - \ - __asm__ volatile("push %%eax ;" \ - "xchg %%eax, %0 ;" \ - "pop %%eax" : : "m" (xchangeDummy)); \ - __asm__ volatile("push %%eax ;" \ - "push %%ebx ;" \ - "push %%ecx ;" \ - "push %%edx ;" \ - "movl $0,%%eax ;" \ - "cpuid ;" \ - "pop %%edx ;" \ - "pop %%ecx ;" \ - "pop %%ebx ;" \ - "pop %%eax" : /* no outputs */ : /* no inputs */); \ - } while (0) - - -/* Get a new VB from the pool of vertex buffers in AGP space */ -/* NOTE: By default the primitive type for a VB is set to individual tris */ -#define R128CCE_GET_NEW_VB(r128ctx) \ - do { \ - r128CCEVertBufPtr vb = &r128ctx->vb; \ - int to = 0; \ - int fd = r128ctx->r128Screen->driScreen->fd; \ - int num; \ - int index; \ - int size; \ - \ - vb->buf = NULL; \ - \ - LOCK_HARDWARE(r128ctx); \ - while (!vb->buf && to++ < r128ctx->CCEtimeout) { \ - /* Ask the kernel a new vertex buffer */ \ - num = drmR128GetVertexBuffers(fd, 1, &index, &size); \ - \ - if (num > 0) { \ - vb->buf = (CARD32 *)(r128ctx->r128Screen-> \ - vbBufs->list[index].address); \ - vb->index = index; \ - vb->start = index*r128ctx->r128Screen->vbBufSize; \ - vb->size = size/sizeof(r128_vertex); \ - vb->count = 0; \ - vb->prim = DRM_R128_PRIM_TRI_LIST; \ - vb->done = GL_FALSE; \ - } \ - } \ - UNLOCK_HARDWARE(r128ctx); \ - \ - if (!vb->buf) { \ - (void)drmR128EngineReset(fd); \ - fprintf(stderr, "Error: Could not get new VB... exiting\n"); \ - exit(-1); \ - } \ - } while (0) - -/* Submit a VB to the hardware for processing */ -/* NOTE: This macro is only called while holding the hardware lock */ -#define R128CCE_SUBMIT_VB(r128ctx) \ - do { \ - int index = r128ctx->vb.index; \ - int size = r128ctx->vb.count; \ - int fd = r128ctx->r128Screen->driScreen->fd; \ - int to = 0; \ - int ret; \ - CARD32 prim; \ - \ - switch (r128ctx->vb.prim) { \ - case DRM_R128_PRIM_NONE: \ - prim = R128_CCE_VC_CNTL_PRIM_TYPE_NONE; \ - break; \ - case DRM_R128_PRIM_POINT: \ - prim = R128_CCE_VC_CNTL_PRIM_TYPE_POINT; \ - break; \ - case DRM_R128_PRIM_LINE: \ - prim = R128_CCE_VC_CNTL_PRIM_TYPE_LINE; \ - break; \ - case DRM_R128_PRIM_POLY_LINE: \ - prim = R128_CCE_VC_CNTL_PRIM_TYPE_POLY_LINE; \ - break; \ - case DRM_R128_PRIM_TRI_LIST: \ - prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST; \ - break; \ - case DRM_R128_PRIM_TRI_FAN: \ - prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_FAN; \ - break; \ - case DRM_R128_PRIM_TRI_STRIP: \ - prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_STRIP; \ - break; \ - case DRM_R128_PRIM_TRI_TYPE2: \ - prim = R128_CCE_VC_CNTL_PRIM_TYPE_TRI_TYPE2; \ - break; \ - default: \ - prim = R128_CCE_VC_CNTL_PRIM_TYPE_NONE; \ - break; \ - } \ - \ - /* Send the vertex buffer to the hardware */ \ - BEGIN_CLIP_LOOP(r128ctx); \ - \ - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_INDX_PRIM, 3); \ - R128CCE(r128ctx->r128Screen->vbOffset + r128ctx->vb.start); \ - R128CCE(r128ctx->vb.count); \ - R128CCE(R128_FULL_VERTEX_FORMAT); \ - R128CCE(prim | R128_CCE_VC_CNTL_PRIM_WALK_LIST | \ - (r128ctx->vb.count << R128_CCE_VC_CNTL_NUM_SHIFT)); \ - R128CCE_SUBMIT_PACKETS(); \ - \ - END_CLIP_LOOP(r128ctx); \ - \ - /* Tell the kernel to release the vertex buffer */ \ - do { \ - ret = drmR128FlushVertexBuffers(fd, 1, &index, &size, \ - r128ctx->vb.prim); \ - } while (ret < 0 && ret == -EBUSY && to++ < r128ctx->CCEtimeout); \ - if (ret < 0) { \ - (void)drmR128EngineReset(fd); \ - fprintf(stderr, "Error: Could not flush VB... exiting\n"); \ - exit(-1); \ - } \ - \ - r128ctx->vb.done = GL_TRUE; \ - } while (0) - -/* Flush the vertex buffer (assuming we already hold the lock) */ -#define R128CCE_FLUSH_VB(r128ctx) \ - do { \ - if (r128ctx->vb.count && !r128ctx->vb.done) { \ - /* FIXME: Is this _really_ needed? */ \ - if (!R128CCE_USE_RING_BUFFER(r128ctx->r128Screen->CCEMode)) \ - R128CCE_WAIT_FOR_IDLE(r128ctx); \ - \ - R128CCE_SUBMIT_VB(r128ctx); \ - } \ - } while (0) - -/* Flush the vertex buffer */ -#define R128CCE_FLUSH_VB_LOCK(r128ctx) \ - do { \ - LOCK_HARDWARE(r128ctx); \ - R128CCE_FLUSH_VB(r128ctx); \ - UNLOCK_HARDWARE(r128ctx); \ - } while (0) - -/* Reserve space in a VB to store `n' vertices, and set the pointer `p' - to point to the next vertex in the current VB. If adding these - vertices to the VB would exceed the size of the VB, then flush the - current VB, get a new one from the pool of VBs, reserve space in the - new VB for the `n' vertices, and set the pointer `p' to point to the - first vertex in the new VB. */ -#define R128CCE_ALLOC_VB_SPACE(r128ctx, p, n) \ - do { \ - r128CCEVertBufPtr vb = &r128ctx->vb; \ - \ - if (vb->done) R128CCE_GET_NEW_VB(r128ctx); \ - \ - if (vb->count + (n) > vb->size) { \ - R128CCE_FLUSH_VB_LOCK(r128ctx); \ - R128CCE_GET_NEW_VB(r128ctx); \ - } \ - \ - (p) = (r128_vertex *)vb->buf + vb->count; \ - vb->count += (n); \ - } while (0) - -#endif -#endif /* _R128_CCEVB_H_ */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_clear.c b/xc/lib/GL/mesa/src/drv/r128/r128_clear.c index 9ab0581b0..725b0caef 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_clear.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_clear.c @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -77,7 +77,7 @@ void r128ClearDepthBuffer(r128ContextPtr r128ctx, GLboolean all, LOCK_HARDWARE(r128ctx); /* Flush any outstanding vertex buffers */ - R128CCE_FLUSH_VB(r128ctx); + r128FlushVerticesLocked(r128ctx); /* Init the clip rects here in case they changed during the LOCK_HARDWARE macro */ @@ -142,10 +142,14 @@ void r128ClearDepthBuffer(r128ContextPtr r128ctx, GLboolean all, /* NOTE: The restore of TEX_CNTL_C and R128_DP_WRITE_MASK is handled by vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ r128ctx->dirty |= R128_UPDATE_CONTEXT; - r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; +/* r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; */ + r128ctx->dirty_context |= (R128_CTX_MISC | + R128_CTX_ENGINESTATE | + R128_CTX_ALPHASTATE); + #endif - R128CCE_SUBMIT_PACKETS(); + R128CCE_SUBMIT_PACKET(); UNLOCK_HARDWARE(r128ctx); } @@ -183,7 +187,7 @@ void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all, LOCK_HARDWARE(r128ctx); /* Flush any outstanding vertex buffers */ - R128CCE_FLUSH_VB(r128ctx); + r128FlushVerticesLocked(r128ctx); /* Init the clip rects here in case they changed during the LOCK_HARDWARE macro */ @@ -239,10 +243,13 @@ void r128ClearColorBuffer(r128ContextPtr r128ctx, GLboolean all, /* NOTE: The restore of TEX_CNTL_C is handled by vvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvvv */ r128ctx->dirty |= R128_UPDATE_CONTEXT; - r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; +/* r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; */ + r128ctx->dirty_context |= (R128_CTX_MISC | + R128_CTX_ENGINESTATE | + R128_CTX_ALPHASTATE); #endif - R128CCE_SUBMIT_PACKETS(); + R128CCE_SUBMIT_PACKET(); UNLOCK_HARDWARE(r128ctx); } 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 01573f559..9bbab1dc5 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_context.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.c @@ -68,14 +68,6 @@ GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual, r128ctx->driContext = driContextPriv; r128ctx->driDrawable = NULL; /* Set by XMesaMakeCurrent */ - if (getenv("LIBGL_SOFTWARE_RENDERING")) - r128ctx->SWonly = GL_TRUE; - else - r128ctx->SWonly = GL_FALSE; - if (getenv("LIBGL_NO_SOFTWARE_FALLBACKS")) - r128ctx->SWfallbackDisable = GL_TRUE; - else - r128ctx->SWfallbackDisable = GL_FALSE; r128scrn = r128ctx->r128Screen = (r128ScreenPtr)(driContextPriv->driScreenPriv->private); @@ -92,17 +84,7 @@ GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual, r128ctx->useFastPath = GL_FALSE; - r128ctx->vb.start = 0; - r128ctx->vb.count = 0; - r128ctx->vb.size = 0; - r128ctx->vb.index = 0; - r128ctx->vb.buf = NULL; - r128ctx->vb.done = GL_TRUE; - - if (r128scrn->IsPCI || getenv("LIBGL_DISABLE_VERTEX_BUFFERS")) - r128ctx->disableVB = GL_TRUE; - else - r128ctx->disableVB = GL_FALSE; + r128ctx->vert_buf = NULL; r128ctx->CCEbuf = (CARD32 *)malloc(sizeof(*r128ctx->CCEbuf) * r128scrn->ringEntries); @@ -125,18 +107,51 @@ GLboolean r128CreateContext(Display *dpy, GLvisual *glVisual, r128DDInitSpanFuncs(glCtx); r128DDInitTextureFuncs(glCtx); + /* Do this after initialization of r128ctx->Fallback in InitState(). + */ + if (getenv("LIBGL_SOFTWARE_RENDERING")) + r128ctx->Fallback |= R128_FALLBACK_SWONLY; + + /* KW: No vertex buffer code for PCI cards -- for now fallback to + * software always. + * GTH: There is support there, but I'm seeing strange behaviour + * with it enabled. I'll leave the software fallbacks in place + * for now. + */ + if (r128scrn->IsPCI) + r128ctx->Fallback |= R128_FALLBACK_SWONLY; + + if (getenv("LIBGL_NO_SOFTWARE_FALLBACKS")) + r128ctx->SWfallbackDisable = GL_TRUE; + else + r128ctx->SWfallbackDisable = GL_FALSE; + glCtx->Driver.TriangleCaps = (DD_TRI_CULL | DD_TRI_LIGHT_TWOSIDE | DD_TRI_OFFSET); -#if 0 - /* FIXME */ - glCtx->TriangleCaps |= DD_CLIP_FOG_COORD; -#endif /* Reset Mesa's current 2D texture pointers to the driver's textures */ glCtx->Shared->DefaultD[2][0].DriverData = NULL; glCtx->Shared->DefaultD[2][1].DriverData = NULL; + /* KW: Set the maximum texture size small enough that we can + * guarentee that both texture units can bind a maximal texture + * and have them both in on-card memory at once. (Kevin or + * Gareth: Please check these numbers are OK) + */ + if (r128scrn->texSize[0] < 2*1024*1024) { + glCtx->Const.MaxTextureLevels = 9; + glCtx->Const.MaxTextureSize = 1<<8; + } else if (r128scrn->texSize[0] < 8*1024*1024) { + glCtx->Const.MaxTextureLevels = 10; + glCtx->Const.MaxTextureSize = 1<<9; + } else { + glCtx->Const.MaxTextureLevels = 11; + glCtx->Const.MaxTextureSize = 1<<10; + } + + glCtx->Const.MaxTextureUnits = 2; + /* If Mesa has current a vertex buffer, make sure the driver's VB data is up to date */ if (glCtx->VB) r128DDRegisterVB(glCtx->VB); 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 189a22cbe..f362338d5 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_context.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_context.h @@ -37,9 +37,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef GLX_DIRECT_RENDERING +struct r128_context; +typedef struct r128_context r128ContextRec; +typedef struct r128_context *r128ContextPtr; + #include "r128_texobj.h" #include "r128_fastpath.h" -#include "r128_ccevb.h" /* Flags for what needs to be updated before a new primitive is rendered */ #define R128_CLEAN 0x0000 @@ -74,6 +77,9 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define R128_FALLBACK_READ_BUFFER 0x0004 #define R128_FALLBACK_COLORMASK 0x0008 #define R128_FALLBACK_STIPPLE 0x0010 +#define R128_FALLBACK_SWONLY 0x0020 +#define R128_FALLBACK_RENDER_MODE 0x0040 +#define R128_FALLBACK_MULTIDRAW 0x0080 /* NOTE: The groups below need to be kept together so that a single memcpy can be used to transfer data to the ring buffer */ @@ -135,12 +141,16 @@ typedef struct { CARD32 pc_gui_ctlstat; /* 0x1748 */ } r128ContextRegs; -typedef struct { +struct r128_context { GLcontext *glCtx; /* Mesa context */ int dirty; /* Hardware state to be updated */ int dirty_context; /* Context state to be updated */ - int SWonly; /* Force software-only rendering */ + int vertsize; /* Size of current vertices */ + CARD32 vc_format; /* Format of current vertices */ + int multitex; + GLfloat depth_scale; + int SWfallbackDisable; /* Disable software fallbacks */ r128TexObjPtr CurrentTexObj[2]; /* Ptr to current texture @@ -166,8 +176,15 @@ typedef struct { int RenderIndex; /* Render state function index */ r128InterpFunc interp; /* Current vert interp function */ - r128CCEVertBuf vb; /* VB currently being filled */ - int disableVB; /* Disable the use of vertex buffers */ + drmBufPtr vert_buf; /* VB currently being filled */ + + drmBufPtr elt_buf, retained_buf; + GLushort *first_elt, *next_elt, *last_elt; + GLfloat *next_vert, *last_vert; + CARD32 next_vert_index; + CARD32 first_vert_index; + struct r128_elt_tab *elt_tab; + GLfloat device_matrix[16]; points_func PointsFunc; /* Current Points, Line, Triangle */ line_func LineFunc; /* and Quad rendering functions */ @@ -202,7 +219,7 @@ typedef struct { __DRIdrawablePrivate *driDrawable; /* DRI drawable bound to this ctx */ r128ScreenPtr r128Screen; /* Screen private DRI data */ -} r128ContextRec, *r128ContextPtr; +}; #define R128_MESACTX(r128ctx) ((r128ctx)->glCtx) #define R128_DRIDRAWABLE(r128ctx) ((r128ctx)->driDrawable) 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 f270cbe13..b621954f4 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_dd.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_dd.c @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -50,10 +50,6 @@ static GLbitfield r128DDClear(GLcontext *ctx, GLbitfield mask, GLboolean all, { r128ContextPtr r128ctx = R128_CONTEXT(ctx); - if (r128ctx->SWonly) { - /* FIXME: Provide software fallback for this case?? */ - } - if (mask & DD_FRONT_LEFT_BIT) { r128ClearColorBuffer(r128ctx, all, x, y, width, height, r128ctx->r128Screen->fbX, @@ -100,7 +96,7 @@ static const GLubyte *r128DDGetString(GLcontext *ctx, GLenum name) case GL_VENDOR: return (GLubyte *)"Precision Insight, Inc."; case GL_RENDERER: - return (GLubyte *)"Mesa DRI Rage128 20000607"; + return (GLubyte *)"Mesa DRI Rage128 20000320"; default: return NULL; } @@ -114,7 +110,7 @@ static void r128DDFlush(GLcontext *ctx) { r128ContextPtr r128ctx = R128_CONTEXT(ctx); - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); } /* Make sure all commands have been sent to the hardware and have @@ -124,21 +120,19 @@ static void r128DDFinish(GLcontext *ctx) r128ContextPtr r128ctx = R128_CONTEXT(ctx); r128DDFlush(ctx); - R128CCE_WAIT_FOR_IDLE_LOCK(r128ctx); + r128WaitForIdle(r128ctx); } -/* Return various parameters requested by Mesa */ +/* Return various parameters requested by Mesa (this is deprecated) */ static GLint r128DDGetParameteri(const GLcontext *ctx, GLint param) { switch (param) { -#if 0 - /* FIXME: Support for these needs to be added to Mesa */ - case DD_MAX_TEXTURE_SIZE: return 1024; - case DD_MAX_TEXTURES: return 2; -#endif -#if 0 - case DD_HAVE_HARDWARE_FOG: return 1; /* FIXME: Add HW fog support */ -#endif + /* Hardware fog isn't working yet -- however returning zero + * here means that it looks like fog is working in some cases. + * It is less confusing to simply have it never work until it + * is actually fixed. + */ + case DD_HAVE_HARDWARE_FOG: return 1; default: return 0; } } diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c b/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c index 330e5a23d..cb0568321 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_fastpath.c @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -45,16 +45,20 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* FIXME: These routines were copied from the i810 driver, and were only slightly modified for the Rage 128. They still need to be optmizied - and cleaned up. Also, support for USE_RHW2 needs to be added. */ + and cleaned up. Also, support for USE_RHW2 needs to be added. + + KW: The fastpath never does projective texturing, so RHW2 support + isn't necesary here. +*/ typedef struct r128_fast_table { r128BuildVerticesFunc build_vertices; r128InterpFunc interp; } r128FastPathTable; -#define POINT(x) r128DrawPointVB(r128ctx, &vert[x].v, psize) -#define LINE(x,y) r128DrawLineVB(r128ctx, &vert[x].v, &vert[y].v, lwidth) -#define TRI(x,y,z) r128DrawTriangleVB(r128ctx, &vert[x].v, &vert[y].v, &vert[z].v) +#define POINT(x) r128DrawPointVB(r128ctx, &vert[x], psize) +#define LINE(x,y) r128DrawLineVB(r128ctx, &vert[x], &vert[y], lwidth) +#define TRI(x,y,z) r128DrawTriangleVB(r128ctx, &vert[x], &vert[y], &vert[z]) /* Direct, and no clipping required. The clip funcs have not been written yet, so this is only useful for the fast path. */ @@ -227,7 +231,7 @@ static void r128TriClip(GLuint **p_elts, /* Convert the planar polygon to a list of triangles */ out = inlist[in]; - + for (i = 2 ; i < n ; i++) { elts[0] = out[0]; elts[1] = out[i-1]; @@ -357,10 +361,10 @@ do { \ /* Pack rgba and/or texture into the remaining half of a 32 byte vertex. */ #define CLIP_UBYTE_COLOR 4 -#define CLIP_UBYTE_B 0 -#define CLIP_UBYTE_G 1 +#define CLIP_UBYTE_B 0 +#define CLIP_UBYTE_G 1 #define CLIP_UBYTE_R 2 -#define CLIP_UBYTE_A 3 +#define CLIP_UBYTE_A 3 #define CLIP_S0 6 #define CLIP_T0 7 #define CLIP_S1 8 @@ -405,7 +409,7 @@ static void r128RenderElementsDirect(struct vertex_buffer *VB) GLuint nr = VB->EltPtr->count; render_func func = render_tab_r128_smooth_indirect[prim]; GLuint p = 0; - + if (r128ctx->dirty) r128UpdateHWState(r128ctx); do { @@ -427,28 +431,13 @@ static void r128ProjectVertices(struct vertex_buffer *VB) m[MAT_TX] = mat->m[MAT_TX]; m[MAT_SY] = -mat->m[MAT_SY]; m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h; - m[MAT_SZ] = mat->m[MAT_SZ]; - m[MAT_TZ] = mat->m[MAT_TZ]; - - switch (ctx->Visual->DepthBits) { - case 16: m[MAT_SZ] /= 65536.0; m[MAT_TZ] /= 65536.0; break; - case 24: m[MAT_SZ] /= 16777216.0; m[MAT_TZ] /= 16777216.0; break; - case 32: m[MAT_SZ] /= 4294967296.0; m[MAT_TZ] /= 4294967296.0; break; - default: m[MAT_SZ] /= 65536.0; m[MAT_TZ] /= 65536.0; break; - } + m[MAT_SZ] = mat->m[MAT_SZ] * r128ctx->depth_scale; + m[MAT_TZ] = mat->m[MAT_TZ] * r128ctx->depth_scale; -#if USE_RHW2 - /* FIXME: Handle RHW2?? */ - gl_project_v16(r128VB->verts[VB->CopyStart].f, - r128VB->verts[r128VB->last_vert].f, - m, - 16 * 4); -#else gl_project_v16(r128VB->verts[VB->CopyStart].f, r128VB->verts[r128VB->last_vert].f, m, 16 * 4); -#endif } /* Project clipped vertices from clip to device space */ @@ -464,30 +453,14 @@ static void r128ProjectClippedVertices(struct vertex_buffer *VB) m[MAT_TX] = mat->m[MAT_TX]; m[MAT_SY] = -mat->m[MAT_SY]; m[MAT_TY] = -mat->m[MAT_TY] + r128ctx->driDrawable->h; - m[MAT_SZ] = mat->m[MAT_SZ]; - m[MAT_TZ] = mat->m[MAT_TZ]; - - switch (ctx->Visual->DepthBits) { - case 16: m[MAT_SZ] /= 65536.0; m[MAT_TZ] /= 65536.0; break; - case 24: m[MAT_SZ] /= 16777216.0; m[MAT_TZ] /= 16777216.0; break; - case 32: m[MAT_SZ] /= 4294967296.0; m[MAT_TZ] /= 4294967296.0; break; - default: m[MAT_SZ] /= 65536.0; m[MAT_TZ] /= 65536.0; break; - } + m[MAT_SZ] = mat->m[MAT_SZ] * r128ctx->depth_scale; + m[MAT_TZ] = mat->m[MAT_TZ] * r128ctx->depth_scale; -#if USE_RHW2 - /* FIXME: Handle RHW2?? */ - gl_project_clipped_v16(r128VB->verts[VB->CopyStart].f, - r128VB->verts[r128VB->last_vert].f, - m, - 16 * 4, - VB->ClipMask + VB->CopyStart); -#else gl_project_clipped_v16(r128VB->verts[VB->CopyStart].f, r128VB->verts[r128VB->last_vert].f, m, 16 * 4, VB->ClipMask + VB->CopyStart); -#endif } static r128FastPathTable r128FastTab[0x80]; diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_init.h b/xc/lib/GL/mesa/src/drv/r128/r128_init.h index fcaf70a51..2d58242a9 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_init.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_init.h @@ -47,14 +47,8 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_screen.h" #include "r128_context.h" -/* NOTE: The vertex buffer code is currently unstable because of the - switches between CCE and MMIO mode in the X server. Fixing the X - server to use the CCE should fix this problem. So, for now, it is - recommended that you do not use it. */ - #define DEBUG 1 #define DEBUG_LOCKING 1 -#define USE_FAST_PATH 1 #define USE_USER_SPACE_RING 0 @@ -69,6 +63,12 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. extern int R128_DEBUG_FLAGS; +#else + +#define R128_DEBUG_FLAGS 0 + +#endif + #define DEBUG_VERBOSE_2D 0x0001 #define DEBUG_VERBOSE_CCE 0x0008 #define DEBUG_VERBOSE_OUTREG 0x0010 @@ -82,11 +82,5 @@ extern int R128_DEBUG_FLAGS; #define DEBUG_VERBOSE_DRI 0x2000 #define DEBUG_VERBOSE_IOCTL 0x4000 -#else - -#define R128_DEBUG_FLAGS 0 - -#endif - #endif #endif /* _R128_INIT_H_ */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_lock.h b/xc/lib/GL/mesa/src/drv/r128/r128_lock.h index 7fd81f807..91a65c210 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_lock.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_lock.h @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -126,7 +126,7 @@ extern int prevLockLine; #define END_CLIP_LOOP(CC) \ R128CCE0(R128_CCE_PACKET0, R128_AUX_SC_CNTL, 0); \ R128CCE(0x00000000); \ - R128CCE_SUBMIT_PACKETS(); \ + R128CCE_SUBMIT_PACKET(); \ } \ } while (0) diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c index 55487ffcd..74ad8395f 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_pipeline.c @@ -55,7 +55,6 @@ static struct gl_pipeline_stage r128FastStage = { return GL_FALSE */ GLboolean r128DDBuildPrecalcPipeline(GLcontext *ctx) { -#if USE_FAST_PATH r128ContextPtr r128ctx = R128_CONTEXT(ctx); struct gl_pipeline *pipe = &ctx->CVA.pre; @@ -90,17 +89,16 @@ GLboolean r128DDBuildPrecalcPipeline(GLcontext *ctx) ctx->CVA.VB->ClipAndMask = CLIP_ALL_BITS; ctx->Array.NewArrayState |= ctx->Array.Summary; } -#endif return GL_FALSE; } + /* Register the pipeline with our stages included */ GLuint r128RegisterPipelineStages(struct gl_pipeline_stage *out, const struct gl_pipeline_stage *in, GLuint nr) { -#if USE_FAST_PATH int i; for (i = 0; i < nr; i++) { @@ -120,7 +118,6 @@ GLuint r128RegisterPipelineStages(struct gl_pipeline_stage *out, break; } } -#endif return nr; } 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 64fa94ebd..3f2f0a17f 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_screen.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_screen.c @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -50,46 +50,6 @@ r128ScreenPtr r128CreateScreen(__DRIscreenPrivate *sPriv) { r128ScreenPtr r128Screen; R128DRIPtr r128DRIPriv = (R128DRIPtr)sPriv->pDevPriv; - int major, minor, patch; - - /* Check that the DRI version is compatible */ - if (XF86DRIQueryVersion(sPriv->display, &major, &minor, &patch)) { - if (major != 3 || minor != 0 || patch < 0) { - char msg[1000]; - sprintf(msg, - "r128 DRI driver expected DRI version 3.0.x " - "but got version %d.%d.%d", - major, minor, patch); - __driMesaMessage(msg); - return NULL; - } - } - - /* Check that the DDX driver version is compatible */ - if (sPriv->ddxMajor != 3 || - sPriv->ddxMinor != 1 || - sPriv->ddxPatch < 0) { - char msg[1000]; - sprintf(msg, - "r128 DRI driver expected DDX driver version 3.1.x " - "but got version %d.%d.%d", - sPriv->ddxMajor, sPriv->ddxMinor, sPriv->ddxPatch); - __driMesaMessage(msg); - return NULL; - } - - /* Check that the DRM driver version is compatible */ - if (sPriv->drmMajor != 1 || - sPriv->drmMinor != 0 || - sPriv->drmPatch < 0) { - char msg[1000]; - sprintf(msg, - "r128 DRI driver expected DRM driver version 1.0.x " - "but got version %d.%d.%d", - sPriv->drmMajor, sPriv->drmMinor, sPriv->drmPatch); - __driMesaMessage(msg); - return NULL; - } /* Allocate the private area */ r128Screen = (r128ScreenPtr)Xmalloc(sizeof(*r128Screen)); @@ -269,6 +229,8 @@ r128ScreenPtr r128CreateScreen(__DRIscreenPrivate *sPriv) r128Screen->driScreen = sPriv; + r128InitVertexBuffers(r128Screen); + r128FastPathInit(); r128TriangleFuncsInit(); r128SetupInit(); 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 b5d1774fd..97e70b1c3 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_span.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_span.c @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -95,7 +95,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define HW_LOCK() \ r128ContextPtr r128ctx = R128_CONTEXT(ctx); \ LOCK_HARDWARE(r128ctx); \ - R128CCE_WAIT_FOR_IDLE(r128ctx); + r128WaitForIdleLocked(r128ctx); #define HW_CLIPLOOP() \ do { \ @@ -166,10 +166,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* 16 bit depthbuffer functions */ #define WRITE_DEPTH(_x, _y, d) \ - *(GLdepth *)(buf + _x*2 + _y*pitch) = d + *(GLushort *)(buf + _x*2 + _y*pitch) = d; #define READ_DEPTH(d, _x, _y) \ - d = *(GLdepth *)(buf + _x*2 + _y*pitch) + d = *(GLushort *)(buf + _x*2 + _y*pitch) #define TAG(x) r128##x##_16 #include "depthtmp.h" @@ -201,10 +201,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* 24 bit depthbuffer functions */ #define WRITE_DEPTH(_x, _y, d) \ - *(GLdepth *)(buf + _x*3 + _y*pitch) = d + *(GLuint *)(buf + _x*3 + _y*pitch) = d #define READ_DEPTH(d, _x, _y) \ - d = *(GLdepth *)(buf + _x*3 + _y*pitch) + d = *(GLuint *)(buf + _x*3 + _y*pitch) #define TAG(x) r128##x##_24 #include "depthtmp.h" @@ -237,10 +237,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. /* 32 bit depthbuffer functions */ #define WRITE_DEPTH(_x, _y, d) \ - *(GLdepth *)(buf + _x*4 + _y*pitch) = d + *(GLuint *)(buf + _x*4 + _y*pitch) = d #define READ_DEPTH(d, _x, _y) \ - d = *(GLdepth *)(buf + _x*4 + _y*pitch) + d = *(GLuint *)(buf + _x*4 + _y*pitch) #define TAG(x) r128##x##_32 #include "depthtmp.h" 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 3d1ceaa24..981874493 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_state.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_state.c @@ -45,6 +45,7 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_tex.h" #include "mmath.h" +#include "pb.h" #define INTERESTED (~(NEW_MODELVIEW | \ NEW_PROJECTION | \ @@ -61,6 +62,12 @@ static void r128DDUpdateState(GLcontext *ctx) fprintf(stderr, "r128DDUpdateState(%p)\n", ctx); } + /* Need to do this here to detect texture fallbacks before + * setting triangle functions. + */ + if (r128ctx->dirty & R128_UPDATE_TEXSTATE) + r128UpdateHWState(r128ctx); + if (ctx->NewState & INTERESTED) { r128ChooseRenderState(ctx); r128ChooseRasterSetupFunc(ctx); @@ -87,16 +94,46 @@ static void r128DDUpdateHWState(GLcontext *ctx) r128UpdateHWState(r128ctx); } + +/* This is called when mesa switches between rendering triangle + * primitives (such as GL_POLYGON, GL_QUADS, GL_TRIANGLE_STRIP, etc), + * and lines, points and bitmaps. + * + * As the r128 uses triangles to render lines and points, it is + * necessary to turn off hardware culling when rendering these + * primitives. + */ static void r128DDReducedPrimitiveChange(GLcontext *ctx, GLenum prim) { - r128ContextPtr r128ctx = R128_CONTEXT(ctx); + r128ContextPtr r128ctx = R128_CONTEXT(ctx); + CARD32 f = r128ctx->regs.pm4_vc_fpu_setup; + + f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID; + + /* Should really use an intermediate value to hold this rather + * than recalculating all the time. + */ + if (prim == GL_POLYGON && ctx->Polygon.CullFlag) { + switch (ctx->Polygon.CullFaceMode) { + case GL_FRONT: f &= ~R128_FRONTFACE_SOLID; break; + case GL_BACK: f &= ~R128_BACKFACE_SOLID; break; + case GL_FRONT_AND_BACK: f &= ~(R128_BACKFACE_SOLID | + R128_FRONTFACE_SOLID); break; + default: + } + } - /* FIXME: Also need to flush between tris and tristrips/fans when we - support them directly */ - R128CCE_FLUSH_VB_LOCK(r128ctx); + if (r128ctx->regs.pm4_vc_fpu_setup != f) { + r128FlushVertices(r128ctx); + r128ctx->regs.pm4_vc_fpu_setup = f; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_SETUPSTATE; + } } -static void r128DDClearColor(GLcontext *ctx, +static void r128DDClearColor(GLcontext *ctx, GLubyte r, GLubyte g, GLubyte b, GLubyte a) { r128ContextPtr r128ctx = R128_CONTEXT(ctx); @@ -142,7 +179,8 @@ static GLboolean r128DDSetDrawBuffer(GLcontext *ctx, GLenum mode) x += r128ctx->drawX; y += r128ctx->drawY; - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); + r128ctx->regs.window_xy_offset = ((y << R128_WINDOW_Y_SHIFT) | (x << R128_WINDOW_X_SHIFT)); @@ -197,7 +235,7 @@ static GLboolean r128DDColorMask(GLcontext *ctx, ctx->Color.ColorMask[ACOMP]); if (r128ctx->regs.plane_3d_mask_c != mask) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.plane_3d_mask_c = mask; /* FIXME: Load into hardware now??? */ @@ -208,6 +246,7 @@ static GLboolean r128DDColorMask(GLcontext *ctx, return GL_TRUE; } + static void r128DDDither(GLcontext *ctx, GLboolean enable) { } @@ -236,7 +275,7 @@ static void r128DDAlphaFunc(GLcontext *ctx, GLenum func, GLclampf ref) } if (r128ctx->regs.misc_3d_state_cntl_reg != a) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.misc_3d_state_cntl_reg = a; /* FIXME: Load into hardware now??? */ @@ -325,7 +364,7 @@ static void r128DDBlendFunc(GLcontext *ctx, GLenum sfactor, GLenum dfactor) } if (r128ctx->regs.misc_3d_state_cntl_reg != b) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.misc_3d_state_cntl_reg = b; /* FIXME: Load into hardware now??? */ @@ -375,7 +414,7 @@ static void r128DDCullFace(GLcontext *ctx, GLenum mode) } if (r128ctx->regs.pm4_vc_fpu_setup != f) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.pm4_vc_fpu_setup = f; /* FIXME: Load into hardware now??? */ @@ -398,7 +437,7 @@ static void r128DDFrontFace(GLcontext *ctx, GLenum mode) } if (r128ctx->regs.pm4_vc_fpu_setup != f) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.pm4_vc_fpu_setup = f; /* FIXME: Load into hardware now??? */ @@ -427,7 +466,7 @@ static void r128DDDepthFunc(GLcontext *ctx, GLenum func) } if (r128ctx->regs.z_sten_cntl_c != z) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.z_sten_cntl_c = z; /* FIXME: Load into hardware now??? */ @@ -445,7 +484,7 @@ static void r128DDDepthMask(GLcontext *ctx, GLboolean flag) else t &= ~R128_Z_WRITE_ENABLE; if (r128ctx->regs.tex_cntl_c != t) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.tex_cntl_c = t; /* FIXME: Load into hardware now??? */ @@ -454,6 +493,31 @@ static void r128DDDepthMask(GLcontext *ctx, GLboolean flag) } } +static void r128DDLightModelfv(GLcontext *ctx, GLenum pname, + const GLfloat *param) +{ + if (pname == GL_LIGHT_MODEL_COLOR_CONTROL) + { + r128ContextPtr r128ctx = R128_CONTEXT( ctx ); + CARD32 t = r128ctx->regs.tex_cntl_c; + + if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) + t |= R128_SPEC_LIGHT_ENABLE; + else + t &= ~R128_SPEC_LIGHT_ENABLE; + + if (r128ctx->regs.tex_cntl_c != t) { + r128FlushVertices(r128ctx); + r128ctx->regs.tex_cntl_c = t; + + /* FIXME: Load into hardware now??? */ + r128ctx->dirty |= R128_UPDATE_CONTEXT; + r128ctx->dirty_context |= R128_CTX_ENGINESTATE; + } + } +} + + static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state) { r128ContextPtr r128ctx = R128_CONTEXT(ctx); @@ -487,17 +551,19 @@ static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state) case GL_COLOR_MATERIAL: return; case GL_CULL_FACE: - f &= ~(R128_BACKFACE_MASK | R128_FRONTFACE_MASK); - if (state) { - switch (ctx->Polygon.CullFaceMode) { - case GL_FRONT: f |= R128_BACKFACE_SOLID; break; - case GL_BACK: f |= R128_FRONTFACE_SOLID; break; - case GL_FRONT_AND_BACK: break; - default: return; + if (ctx->PB->primitive == GL_POLYGON) { + f &= ~(R128_BACKFACE_MASK | R128_FRONTFACE_MASK); + if (state) { + switch (ctx->Polygon.CullFaceMode) { + case GL_FRONT: f |= R128_BACKFACE_SOLID; break; + case GL_BACK: f |= R128_FRONTFACE_SOLID; break; + case GL_FRONT_AND_BACK: break; + default: return; + } + } else { + f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID; } - } else { - f |= R128_BACKFACE_SOLID | R128_FRONTFACE_SOLID; - } + } break; case GL_DEPTH_TEST: @@ -567,11 +633,11 @@ static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state) case GL_TEXTURE_1D: case GL_TEXTURE_2D: + case GL_TEXTURE_3D: /* This is handled in r128UpdateTex[01]State() */ r128ctx->dirty |= R128_UPDATE_TEXSTATE; break; - case GL_TEXTURE_3D: case GL_TEXTURE_GEN_Q: case GL_TEXTURE_GEN_R: case GL_TEXTURE_GEN_S: @@ -589,7 +655,7 @@ static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state) } if (r128ctx->regs.tex_cntl_c != t) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.tex_cntl_c = t; /* FIXME: Load into hardware now??? */ @@ -597,7 +663,7 @@ static void r128DDEnable(GLcontext *ctx, GLenum cap, GLboolean state) r128ctx->dirty_context |= R128_CTX_ENGINESTATE; } if (r128ctx->regs.pm4_vc_fpu_setup != f) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.pm4_vc_fpu_setup = f; /* FIXME: Load into hardware now??? */ @@ -623,7 +689,7 @@ static void r128DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) case GL_FOG_MODE: mode = (GLenum)(GLint)*param; if (r128ctx->FogMode != mode) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->FogMode = mode; /* FIXME: Load into hardware now??? */ @@ -635,7 +701,7 @@ static void r128DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) case GL_FOG_DENSITY: fog.f = *param; if (r128ctx->regs.fog_3d_table_density != fog.i) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.fog_3d_table_density = fog.i; /* FIXME: Load into hardware now??? */ @@ -647,7 +713,7 @@ static void r128DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) case GL_FOG_START: fog.f = *param; if (r128ctx->regs.fog_3d_table_start != fog.i) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.fog_3d_table_start = fog.i; /* FIXME: Load into hardware now??? */ @@ -659,7 +725,7 @@ static void r128DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) case GL_FOG_END: fog.f = *param; if (r128ctx->regs.fog_3d_table_end != fog.i) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.fog_3d_table_end = fog.i; /* FIXME: Load into hardware now??? */ @@ -672,7 +738,7 @@ static void r128DDFogfv(GLcontext *ctx, GLenum pname, const GLfloat *param) FLOAT_RGBA_TO_UBYTE_RGBA(c, ctx->Fog.Color); col = r128PackColor(32, c[0], c[1], c[2], c[3]); if (r128ctx->regs.fog_color_c != col) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.fog_color_c = col; /* FIXME: Load into hardware now??? */ @@ -741,7 +807,7 @@ void r128DDInitStateFuncs(GLcontext *ctx) ctx->Driver.Fogfv = r128DDFogfv; ctx->Driver.Hint = NULL; ctx->Driver.Lightfv = NULL; - ctx->Driver.LightModelfv = NULL; + ctx->Driver.LightModelfv = r128DDLightModelfv; ctx->Driver.PolygonMode = NULL; ctx->Driver.Scissor = r128DDScissor; ctx->Driver.ShadeModel = NULL; @@ -784,6 +850,14 @@ void r128DDInitState(r128ContextPtr r128ctx) break; } + /* Precalculate the depth scale while we're here */ + switch (r128ctx->glCtx->Visual->DepthBits) { + case 16: r128ctx->depth_scale = 1.0 / 65536.0; break; + case 24: r128ctx->depth_scale = 1.0 / 16777216.0; break; + case 32: r128ctx->depth_scale = 1.0 / 4294967296.0; break; + default: r128ctx->depth_scale = 1.0 / 65536.0; break; + } + r128ctx->dirty = R128_ALL_DIRTY; r128ctx->dirty_context = R128_CTX_ALL_DIRTY; @@ -1003,6 +1077,17 @@ static void r128UploadFogTable(r128ContextPtr r128ctx) R128CCE0(R128_CCE_PACKET0_ONE_REG_WR, R128_FOG_TABLE_DATA, 255); + + if (0) + fprintf(stderr, "uploading fog table for %s\n", + gl_lookup_enum_by_nr(r128ctx->FogMode)); + + + /* KW: I'm not sure we're doing enough here - shouldn't density + * play a role in calculating the exp and exp2 tables -- is the + * card really doing exponent calculations of its own? Need to + * see the spec... + */ switch (r128ctx->FogMode) { case GL_LINEAR: for (i = 0; i < 256; i++) { @@ -1011,12 +1096,20 @@ static void r128UploadFogTable(r128ContextPtr r128ctx) break; case GL_EXP: for (i = 0; i < 256; i++) { - R128CCE(255 - FLOAT_TO_UBYTE(exp(i - 255))); + float arg = (255 - i)/255.0; + float exparg = (exp(arg) - 1) / (M_E - 1); /* range [0,1] */ + int result; + FLOAT_COLOR_TO_UBYTE_COLOR(result, exparg); + R128CCE(result); } break; case GL_EXP2: for (i = 0; i < 256; i++) { - R128CCE(255 - FLOAT_TO_UBYTE(exp((i - 255) * (i - 255)))); + float arg = (255 - i)/255.0; + float exparg = (exp(arg*arg) - 1) / (M_E - 1); /* range [0,1] */ + int result; + FLOAT_COLOR_TO_UBYTE_COLOR(result, exparg); + R128CCE(result); } break; } @@ -1048,7 +1141,7 @@ static void r128LoadContext(r128ContextPtr r128ctx) /* FIXME: Is this _really_ needed? */ if (r128ctx->dirty_context) if (!R128CCE_USE_RING_BUFFER(r128ctx->r128Screen->CCEMode)) - R128CCE_WAIT_FOR_IDLE(r128ctx); + r128WaitForIdleLocked(r128ctx); #endif if (r128ctx->dirty_context & R128_CTX_MISC) { @@ -1163,7 +1256,7 @@ static void r128LoadContext(r128ContextPtr r128ctx) } #endif - R128CCE_SUBMIT_PACKETS(); + R128CCE_SUBMIT_PACKET(); /* Turn off the texture cache flushing */ r128ctx->regs.tex_cntl_c &= ~R128_TEX_CACHE_FLUSH; @@ -1220,7 +1313,7 @@ void r128SetClipRects(r128ContextPtr r128ctx, R128CCE0(R128_CCE_PACKET0, R128_AUX_SC_CNTL, 0); R128CCE(r128ctx->regs.aux_sc_cntl); - R128CCE_SUBMIT_PACKETS(); + R128CCE_SUBMIT_PACKET(); } /* Update the driver's notion of the window position */ @@ -1256,7 +1349,7 @@ static void r128UpdateWindowPosition(r128ContextPtr r128ctx) static void r128UpdateHWStateLocked(r128ContextPtr r128ctx) { if (r128ctx->dirty & R128_REQUIRE_QUIESCENCE) - R128CCE_WAIT_FOR_IDLE(r128ctx); + r128WaitForIdleLocked(r128ctx); /* Update any state that might have changed recently */ diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_swap.c b/xc/lib/GL/mesa/src/drv/r128/r128_swap.c index 6b347023d..d6467970e 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_swap.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_swap.c @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -43,6 +43,10 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_vb.h" #include "r128_swap.h" +static void delay(void) { + /* stop the compiler from optimizing our spin loop away */ +} + /* Copy the back color buffer to the front color buffer */ void r128SwapBuffers(r128ContextPtr r128ctx) { @@ -52,10 +56,7 @@ void r128SwapBuffers(r128ContextPtr r128ctx) XF86DRIClipRectPtr c; int dst_bpp; CARD32 swapAge; - - if (r128ctx->SWonly) { - /* FIXME: Provide software fallback for this case?? */ - } + int i, to = 0; switch (r128ctx->r128Screen->bpp) { case 8: @@ -77,11 +78,15 @@ void r128SwapBuffers(r128ContextPtr r128ctx) LOCK_HARDWARE(r128ctx); /* Flush any outstanding vertex buffers */ - R128CCE_FLUSH_VB(r128ctx); + r128FlushVerticesLocked(r128ctx); /* Throttle the frame rate -- only allow one pending swap buffers request at a time */ - while (r128ctx->lastSwapAge > (swapAge = INREG(R128_SWAP_AGE_REG))); + while ((r128ctx->lastSwapAge > (swapAge = INREG(R128_SWAP_AGE_REG))) && + (to++ < r128ctx->CCEtimeout)) { + /* Don't just sit here hammering the register */ + for (i = 0; i < 1000; i++) delay(); + } /* Init the clip rects here in case they changed during the LOCK_HARDWARE macro */ @@ -117,9 +122,12 @@ void r128SwapBuffers(r128ContextPtr r128ctx) r128ctx->lastSwapAge = swapAge; r128ctx->dirty |= R128_UPDATE_CONTEXT; - r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; +/* r128ctx->dirty_context |= R128_CTX_ALL_DIRTY; */ + r128ctx->dirty_context |= (R128_CTX_MISC | + R128_CTX_ENGINESTATE | + R128_CTX_ALPHASTATE); - R128CCE_SUBMIT_PACKETS(); + R128CCE_SUBMIT_PACKET(); UNLOCK_HARDWARE(r128ctx); } 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 d75345404..51f282462 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_tex.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tex.c @@ -318,7 +318,7 @@ static void r128TexturesGone(r128ContextPtr r128ctx, int heap, int offset, int size, int in_use) { r128TexObjPtr t, tmp; - + foreach_s (t, tmp, &r128ctx->TexObjList[heap]) { if (t->memBlock->ofs >= offset + size || t->memBlock->ofs + t->memBlock->size <= offset) @@ -701,11 +701,12 @@ static void r128UploadSubImage(r128ContextPtr r128ctx, (int)offset, pitch, dwords, level, format); } +#define R128_MAX_BLIT_DWORDS 8192 /* Subdivide the texture if required */ - if (dwords < R128_CCE_PACKET_MAX_DWORDS) { + if (dwords < R128_MAX_BLIT_DWORDS) { rows = height; } else { - rows = (R128_CCE_PACKET_MAX_DWORDS * texelsPerDword) / (2 * width); + rows = (R128_MAX_BLIT_DWORDS * texelsPerDword) / (2 * width); } /* Flush the pixel cache, and mark the contents as Read Invalid */ @@ -713,7 +714,7 @@ static void r128UploadSubImage(r128ContextPtr r128ctx, R128CCE(r128ctx->regs.pc_gui_ctlstat | R128_PC_RI_GUI | R128_PC_FLUSH_GUI); - R128CCE_SUBMIT_PACKETS(); + R128CCE_SUBMIT_PACKET(); /* Build the CCE host data blit header */ R128CCE3(R128_CCE_PACKET3_CNTL_HOSTDATA_BLT, 0); @@ -775,10 +776,10 @@ static void r128UploadSubImage(r128ContextPtr r128ctx, R128CCE(r128ctx->regs.pc_gui_ctlstat | R128_PC_FLUSH_GUI); /* Save the partial blit header */ - R128CCE_SUBMIT_PACKETS(); + R128CCE_SUBMIT_PACKET(); r128ctx->CCEcount = 5; } - + /* Clean up CCE ring buffer */ r128ctx->CCEcount = 0; } @@ -886,7 +887,7 @@ int r128UploadTexImages(r128ContextPtr r128ctx, r128TexObjPtr t) r128ctx->regs.sec_tex_offset[i] = (CARD32)t->bufAddr; } else { for (i = maxLevel; i >= minLevel; i--) - r128ctx->regs.sec_tex_offset[i] = + r128ctx->regs.sec_tex_offset[i] = t->image[maxLevel-i].offset + (CARD32)t->bufAddr; } /* Fix AGP texture offsets */ @@ -958,6 +959,8 @@ static void r128UpdateTex0State(r128ContextPtr r128ctx) return; } + r128ctx->regs.scale_3d_cntl &= ~R128_TEX_CACHE_SPLIT; + /* If this is the first time the texture has been used, then create a new texture object for it. */ t = tObj->DriverData; @@ -1243,7 +1246,7 @@ static void r128UpdateTex0State(r128ContextPtr r128ctx) int minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >> R128_TEX_MIN_SIZE_SHIFT); for (i = maxLevel; i >= minLevel; i--) - r128ctx->regs.prim_tex_offset[i] = + r128ctx->regs.prim_tex_offset[i] = t->image[maxLevel-i].offset + (CARD32)t->bufAddr; } /* Fix AGP texture offsets */ @@ -1280,6 +1283,9 @@ static void r128UpdateTex1State(r128ContextPtr r128ctx) return; } + /* If te1 is enabled, split the texel cache */ + r128ctx->regs.scale_3d_cntl |= R128_TEX_CACHE_SPLIT; + /* If this is the first time the texture has been used, then create a new texture object for it. */ t = tObj->DriverData; @@ -1557,7 +1563,7 @@ static void r128UpdateTex1State(r128ContextPtr r128ctx) int minLevel = ((t->regs.size_pitch & R128_TEX_MIN_SIZE_MASK) >> R128_TEX_MIN_SIZE_SHIFT); for (i = maxLevel; i >= minLevel; i--) - r128ctx->regs.sec_tex_offset[i] = + r128ctx->regs.sec_tex_offset[i] = t->image[maxLevel-i].offset + (CARD32)t->bufAddr; } /* Fix AGP texture offsets */ @@ -1584,6 +1590,9 @@ void r128UpdateTextureState(r128ContextPtr r128ctx) r128ctx->CurrentTexObj[0] = NULL; r128ctx->CurrentTexObj[1] = NULL; + if (r128ctx->glCtx->Enabled & (TEXTURE0_3D|TEXTURE1_3D)) + r128ctx->Fallback |= R128_FALLBACK_TEXTURE; + /* Update the texture unit 0/1 state */ r128UpdateTex0State(r128ctx); r128UpdateTex1State(r128ctx); @@ -1658,13 +1667,13 @@ static void r128DDTexEnv(GLcontext *ctx, GLenum target, GLenum pname, struct gl_texture_unit *texUnit; GLubyte c[4]; CARD32 col; - + /* FIXME: Add texture LOD bias extension */ switch (pname) { case GL_TEXTURE_ENV_MODE: /* TexEnv modes are handled in UpdateTextureState */ - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->dirty |= R128_UPDATE_TEXSTATE; break; case GL_TEXTURE_ENV_COLOR: @@ -1672,7 +1681,7 @@ static void r128DDTexEnv(GLcontext *ctx, GLenum target, GLenum pname, FLOAT_RGBA_TO_UBYTE_RGBA(texUnit->EnvColor, c); col = r128PackColor(32, c[0], c[1], c[2], c[3]); if (r128ctx->regs.constant_color_c != col) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->regs.constant_color_c = col; /* FIXME: Load into hardware now??? */ @@ -1702,7 +1711,7 @@ static void r128DDTexImage(GLcontext *ctx, GLenum target, t = (r128TexObjPtr)tObj->DriverData; if (t) { - if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx); + if (t->bound) r128FlushVertices(r128ctx); /* Destroy the old texture, and upload a new one. The actual uploading of the texture image occurs in the UploadSubImage @@ -1733,7 +1742,7 @@ static void r128DDTexSubImage(GLcontext *ctx, GLenum target, t = (r128TexObjPtr)tObj->DriverData; if (t) { - if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx); + if (t->bound) r128FlushVertices(r128ctx); LOCK_HARDWARE(r128ctx); r128UploadSubImage(r128ctx, t, level, @@ -1765,18 +1774,18 @@ static void r128DDTexParameter(GLcontext *ctx, GLenum target, switch (pname) { case GL_TEXTURE_MIN_FILTER: case GL_TEXTURE_MAG_FILTER: - if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx); + if (t->bound) r128FlushVertices(r128ctx); r128SetTexFilter(t, tObj->MinFilter, tObj->MagFilter); break; case GL_TEXTURE_WRAP_S: case GL_TEXTURE_WRAP_T: - if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx); + if (t->bound) r128FlushVertices(r128ctx); r128SetTexWrap(t, tObj->WrapS, tObj->WrapT); break; - + case GL_TEXTURE_BORDER_COLOR: - if (t->bound) R128CCE_FLUSH_VB_LOCK(r128ctx); + if (t->bound) r128FlushVertices(r128ctx); r128SetTexBorderColor(t, tObj->BorderColor); break; @@ -1793,7 +1802,7 @@ static void r128DDBindTexture(GLcontext *ctx, GLenum target, { r128ContextPtr r128ctx = R128_CONTEXT(ctx); - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); /* Unbind the old texture */ if (r128ctx->CurrentTexObj[ctx->Texture.CurrentUnit]) { @@ -1814,7 +1823,7 @@ static void r128DDDeleteTexture(GLcontext *ctx, if (t) { if (t->bound) { - R128CCE_FLUSH_VB_LOCK(r128ctx); + r128FlushVertices(r128ctx); r128ctx->CurrentTexObj[t->bound-1] = 0; r128ctx->dirty |= R128_UPDATE_TEXSTATE; @@ -1827,7 +1836,7 @@ static void r128DDDeleteTexture(GLcontext *ctx, /* Determine if a texture is currently residing in either AGP/local texture memory */ -static GLboolean r128DDIsTextureResident(GLcontext *ctx, +static GLboolean r128DDIsTextureResident(GLcontext *ctx, struct gl_texture_object *tObj) { r128TexObjPtr t = (r128TexObjPtr)tObj->DriverData; 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 1c1b45daf..00bbe948e 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_tris.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.c @@ -1,4 +1,4 @@ -/* $XFree86$ */ +/* $XFree86$ */ /* -*- c-basic-offset: 4 -*- */ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., @@ -43,378 +43,135 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_tris.h" #include "r128_state.h" -static triangle_func tri_tab[0x40]; /* only 0x20 actually used */ -static quad_func quad_tab[0x40]; /* only 0x20 actually used */ -static line_func line_tab[0x40]; /* less than 0x20 used */ -static points_func points_tab[0x40]; /* less than 0x20 used */ +static triangle_func tri_tab[0x10]; +static quad_func quad_tab[0x10]; +static line_func line_tab[0x10]; +static points_func points_tab[0x10]; /* Draw a triangle from the vertices in the vertex buffer */ -void r128DrawTriangleVB(r128ContextPtr r128ctx, - r128_vertex *v0, - r128_vertex *v1, - r128_vertex *v2) +__inline void r128DrawTriangleVB(r128ContextPtr r128ctx, + r128Vertex *v0, + r128Vertex *v1, + r128Vertex *v2) { - r128_vertex *vbptr; + int vertsize = r128ctx->vertsize; + CARD32 *vb = r128AllocVertexDwords( r128ctx, 3 * vertsize ); + int j; - if (r128ctx->disableVB) { - r128DrawTriangle(r128ctx, v0, v1, v2); - return; - } - - R128CCE_ALLOC_VB_SPACE(r128ctx, vbptr, 3); + for (j = 0 ; j < vertsize ; j++) + vb[j] = v0->ui[j]; - *vbptr++ = *v0; - *vbptr++ = *v1; - *vbptr++ = *v2; -} + vb += vertsize; + for (j = 0 ; j < vertsize ; j++) + vb[j] = v1->ui[j]; -/* Draw a triangle */ -void r128DrawTriangle(r128ContextPtr r128ctx, - r128_vertex *v0, - r128_vertex *v1, - r128_vertex *v2) -{ - LOCK_HARDWARE(r128ctx); - BEGIN_CLIP_LOOP(r128ctx); - -#if USE_RHW2 - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 34); -#else - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 31); -#endif - R128CCE(R128_FULL_VERTEX_FORMAT); - R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST | - R128_CCE_VC_CNTL_PRIM_WALK_RING | - (3 << R128_CCE_VC_CNTL_NUM_SHIFT)); - - R128CCE_SEND_VERTEX(v0); - R128CCE_SEND_VERTEX(v1); - R128CCE_SEND_VERTEX(v2); - - R128CCE_SUBMIT_PACKETS(); - - END_CLIP_LOOP(r128ctx); - UNLOCK_HARDWARE(r128ctx); + vb += vertsize; + for (j = 0 ; j < vertsize ; j++) + vb[j] = v2->ui[j]; } /* Draw a line from the vertices in the vertex buffer */ -void r128DrawLineVB(r128ContextPtr r128ctx, - r128_vertex *v0, r128_vertex *v1, - float width) +__inline void r128DrawLineVB( r128ContextPtr r128ctx, + r128Vertex *tmp0, + r128Vertex *tmp1, + float width ) { - float dx, dy, ix, iy; - r128_vertex *vbptr; + int vertsize = r128ctx->vertsize; + CARD32 *vb = r128AllocVertexDwords( r128ctx, 6 * vertsize ); + float dx, dy, ix, iy; + int j; - /* FIXME: Use r128's line primitive for width 1 lines */ - if (r128ctx->disableVB) { - r128DrawLine(r128ctx, v0, v1, width); - return; - } + dx = tmp0->vert1.x - tmp1->vert1.x; + dy = tmp0->vert1.y - tmp1->vert1.y; - R128CCE_ALLOC_VB_SPACE(r128ctx, vbptr, 3); + ix = width * .5; iy = 0; - dx = v0->x - v1->x; - dy = v0->y - v1->y; + if ((ix<.5) && (ix>0.1)) ix = .5; /* I want to see lines with width + 0.5 also */ - ix = width * 0.5; iy = 0; - if (dx*dx > dy*dy) { - iy = ix; ix = 0; + if (dx * dx > dy * dy) { + iy = ix; ix = 0; } - *vbptr = *v0; vbptr->x = v0->x - ix; vbptr->y = v0->y - iy; - *++vbptr = *v1; vbptr->x = v1->x + ix; vbptr->y = v1->y + iy; - *++vbptr = *v0; vbptr->x = v0->x + ix; vbptr->y = v0->y + iy; - *++vbptr = *v0; vbptr->x = v0->x - ix; vbptr->y = v0->y - iy; - *++vbptr = *v1; vbptr->x = v1->x - ix; vbptr->y = v1->y - iy; - *++vbptr = *v1; vbptr->x = v1->x + ix; vbptr->y = v1->y + iy; + *(float *)&vb[0] = tmp0->vert1.x - ix; + *(float *)&vb[1] = tmp0->vert1.y - iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp0->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp1->vert1.x + ix; + *(float *)&vb[1] = tmp1->vert1.y + iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp1->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp0->vert1.x + ix; + *(float *)&vb[1] = tmp0->vert1.y + iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp0->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp0->vert1.x - ix; + *(float *)&vb[1] = tmp0->vert1.y - iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp0->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp1->vert1.x - ix; + *(float *)&vb[1] = tmp1->vert1.y - iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp1->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp1->vert1.x + ix; + *(float *)&vb[1] = tmp1->vert1.y + iy; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp1->ui[j]; } -/* Draw a line */ -void r128DrawLine(r128ContextPtr r128ctx, - r128_vertex *v0, r128_vertex *v1, - float width) -{ - LOCK_HARDWARE(r128ctx); - if (width != 1) { - float dx, dy, ix, iy; - - dx = v0->x - v1->x; - dy = v0->y - v1->y; - - ix = width * 0.5; iy = 0; - if (dx*dx > dy*dy) { - iy = ix; ix = 0; - } - - BEGIN_CLIP_LOOP(r128ctx); - -#if USE_RHW2 - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 67); -#else - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 61); -#endif - R128CCE(R128_FULL_VERTEX_FORMAT); - R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST | - R128_CCE_VC_CNTL_PRIM_WALK_RING | - (6 << R128_CCE_VC_CNTL_NUM_SHIFT)); - - R128CCEF(v0->x - ix); - R128CCEF(v0->y - iy); - R128CCEF(v0->z); - R128CCEF(v0->rhw); - R128CCE(*(int *)&v0->dif_argb); - R128CCE(*(int *)&v0->spec_frgb); - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCEF(v1->x + ix); - R128CCEF(v1->y + iy); - R128CCEF(v1->z); - R128CCEF(v1->rhw); - R128CCE(*(int *)&v1->dif_argb); - R128CCE(*(int *)&v1->spec_frgb); - R128CCEF(v1->tu0); - R128CCEF(v1->tv0); - R128CCEF(v1->tu1); - R128CCEF(v1->tv1); -#if USE_RHW2 - R128CCEF(v1->rhw2); -#endif - - R128CCEF(v0->x + ix); - R128CCEF(v0->y + iy); - R128CCEF(v0->z); - R128CCEF(v0->rhw); - R128CCE(*(int *)&v0->dif_argb); - R128CCE(*(int *)&v0->spec_frgb); - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCEF(v0->x - ix); - R128CCEF(v0->y - iy); - R128CCEF(v0->z); - R128CCEF(v0->rhw); - R128CCE(*(int *)&v0->dif_argb); - R128CCE(*(int *)&v0->spec_frgb); - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCEF(v1->x - ix); - R128CCEF(v1->y - iy); - R128CCEF(v1->z); - R128CCEF(v1->rhw); - R128CCE(*(int *)&v1->dif_argb); - R128CCE(*(int *)&v1->spec_frgb); - R128CCEF(v1->tu0); - R128CCEF(v1->tv0); - R128CCEF(v1->tu1); - R128CCEF(v1->tv1); -#if USE_RHW2 - R128CCEF(v1->rhw2); -#endif - - R128CCEF(v1->x + ix); - R128CCEF(v1->y + iy); - R128CCEF(v1->z); - R128CCEF(v1->rhw); - R128CCE(*(int *)&v1->dif_argb); - R128CCE(*(int *)&v1->spec_frgb); - R128CCEF(v1->tu0); - R128CCEF(v1->tv0); - R128CCEF(v1->tu1); - R128CCEF(v1->tv1); -#if USE_RHW2 - R128CCEF(v1->rhw2); -#endif - - R128CCE_SUBMIT_PACKETS(); - - END_CLIP_LOOP(r128ctx); - } else { - BEGIN_CLIP_LOOP(r128ctx); - -#if USE_RHW2 - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 23); -#else - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 21); -#endif - R128CCE(R128_FULL_VERTEX_FORMAT); - R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_LINE | - R128_CCE_VC_CNTL_PRIM_WALK_RING | - (2 << R128_CCE_VC_CNTL_NUM_SHIFT)); - - R128CCE_SEND_VERTEX(v0); - R128CCE_SEND_VERTEX(v1); - - R128CCE_SUBMIT_PACKETS(); - - END_CLIP_LOOP(r128ctx); - } - UNLOCK_HARDWARE(r128ctx); -} /* Draw a point from the vertices in the vertex buffer */ -void r128DrawPointVB(r128ContextPtr r128ctx, - r128_vertex *v0, float size) +__inline void r128DrawPointVB( r128ContextPtr r128ctx, + r128Vertex *tmp, float sz ) { - r128_vertex *vbptr; - - /* FIXME: Use r128's point primitive for diameter 1 points */ - if (r128ctx->disableVB) { - r128DrawPoint(r128ctx, v0, size); - return; - } - - R128CCE_ALLOC_VB_SPACE(r128ctx, vbptr, 3); - - *vbptr = *v0; vbptr->x = v0->x - size; vbptr->y = v0->y - size; - *++vbptr = *v0; vbptr->x = v0->x + size; vbptr->y = v0->y - size; - *++vbptr = *v0; vbptr->x = v0->x + size; vbptr->y = v0->y + size; - *++vbptr = *v0; vbptr->x = v0->x + size; vbptr->y = v0->y + size; - *++vbptr = *v0; vbptr->x = v0->x - size; vbptr->y = v0->y + size; - *++vbptr = *v0; vbptr->x = v0->x - size; vbptr->y = v0->y - size; -} - -/* Draw a point */ -void r128DrawPoint(r128ContextPtr r128ctx, - r128_vertex *v0, float size) -{ - LOCK_HARDWARE(r128ctx); - if (size != 0.5) { - BEGIN_CLIP_LOOP(r128ctx); - -#if USE_RHW2 - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 67); -#else - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 61); -#endif - R128CCE(R128_FULL_VERTEX_FORMAT); - R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST | - R128_CCE_VC_CNTL_PRIM_WALK_RING | - (6 << R128_CCE_VC_CNTL_NUM_SHIFT)); - - R128CCEF(v0->x - size); - R128CCEF(v0->y - size); - R128CCEF(v0->z); - R128CCEF(v0->rhw); - R128CCE(*(int *)&v0->dif_argb); - R128CCE(*(int *)&v0->spec_frgb); - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCEF(v0->x + size); - R128CCEF(v0->y - size); - R128CCEF(v0->z); - R128CCEF(v0->rhw); - R128CCE(*(int *)&v0->dif_argb); - R128CCE(*(int *)&v0->spec_frgb); - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCEF(v0->x + size); - R128CCEF(v0->y + size); - R128CCEF(v0->z); - R128CCEF(v0->rhw); - R128CCE(*(int *)&v0->dif_argb); - R128CCE(*(int *)&v0->spec_frgb); - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCEF(v0->x + size); - R128CCEF(v0->y + size); - R128CCEF(v0->z); - R128CCEF(v0->rhw); - R128CCE(*(int *)&v0->dif_argb); - R128CCE(*(int *)&v0->spec_frgb); - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCEF(v0->x - size); - R128CCEF(v0->y + size); - R128CCEF(v0->z); - R128CCEF(v0->rhw); - R128CCE(*(int *)&v0->dif_argb); - R128CCE(*(int *)&v0->spec_frgb); - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCEF(v0->x - size); - R128CCEF(v0->y - size); - R128CCEF(v0->z); - R128CCEF(v0->rhw); - R128CCE(*(int *)&v0->dif_argb); - R128CCE(*(int *)&v0->spec_frgb); - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCE_SUBMIT_PACKETS(); - - END_CLIP_LOOP(r128ctx); - } else { - BEGIN_CLIP_LOOP(r128ctx); - -#if USE_RHW2 - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 12); -#else - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 11); -#endif - R128CCE(R128_FULL_VERTEX_FORMAT); - R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_POINT | - R128_CCE_VC_CNTL_PRIM_WALK_RING | - (1 << R128_CCE_VC_CNTL_NUM_SHIFT)); - - R128CCE_SEND_VERTEX(v0); - - R128CCE_SUBMIT_PACKETS(); - - END_CLIP_LOOP(r128ctx); - } - UNLOCK_HARDWARE(r128ctx); + int vertsize = r128ctx->vertsize; + CARD32 *vb = r128AllocVertexDwords( r128ctx, 6 * vertsize ); + int j; + + *(float *)&vb[0] = tmp->vert1.x - sz; + *(float *)&vb[1] = tmp->vert1.y - sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x + sz; + *(float *)&vb[1] = tmp->vert1.y - sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x + sz; + *(float *)&vb[1] = tmp->vert1.y + sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x + sz; + *(float *)&vb[1] = tmp->vert1.y + sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x - sz; + *(float *)&vb[1] = tmp->vert1.y + sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; + vb += vertsize; + + *(float *)&vb[0] = tmp->vert1.x - sz; + *(float *)&vb[1] = tmp->vert1.y - sz; + for (j = 2 ; j < vertsize ; j++) + vb[j] = tmp->ui[j]; } #define R128_COLOR(to, from) \ @@ -478,36 +235,36 @@ void r128ChooseRenderState(GLcontext *ctx) r128ContextPtr r128ctx = R128_CONTEXT(ctx); GLuint flags = ctx->TriangleCaps; - if (r128ctx->Fallback) return; - - if (r128ctx->SWonly) { - r128ctx->IndirectTriangles = DD_SW_RASTERIZE; - r128ctx->PointsFunc = NULL; - r128ctx->LineFunc = NULL; - r128ctx->TriangleFunc = NULL; - r128ctx->QuadFunc = NULL; - return; - } else { - r128ctx->IndirectTriangles = 0; - } + /* KW: Includes handling of SWonly rendering: + */ + if (r128ctx->Fallback) + return; + + r128ctx->IndirectTriangles = 0; if (flags) { CARD32 index = 0; CARD32 shared = 0; - CARD32 fallback = R128_FALLBACK_BIT; + CARD32 fallback = R128_FALLBACK_BIT; - if (r128ctx->SWfallbackDisable) fallback = 0; /* No fallbacks */ - if (r128ctx->SWonly) shared = fallback; /* Everything's a fallback */ + /* KW: I'd prefer to remove SWfallbackDisable & just use + * R128_FALLBACK_BIT throughout this routine. + */ + if (r128ctx->SWfallbackDisable) fallback = 0; if (flags & DD_FLATSHADE) shared |= R128_FLAT_BIT; - if (flags & DD_MULTIDRAW) shared |= fallback; - if (flags & DD_SELECT) shared |= R128_FALLBACK_BIT; - if (flags & DD_FEEDBACK) shared |= R128_FALLBACK_BIT; + if (flags & DD_TRI_LIGHT_TWOSIDE) shared |= R128_TWOSIDE_BIT; + + /* TODO: Fix mesa so that these can be handled in + * r128ctx->Fallback. + */ + if (flags & (DD_MULTIDRAW | + DD_SELECT | + DD_FEEDBACK)) shared |= R128_FALLBACK_BIT; /* Setup PointFunc */ index = shared; if (flags & DD_POINT_SMOOTH) index |= fallback; - if (flags & DD_POINT_ATTEN) index |= fallback; r128ctx->RenderIndex = index; r128ctx->PointsFunc = points_tab[index]; @@ -526,9 +283,8 @@ void r128ChooseRenderState(GLcontext *ctx) /* Setup TriangleFunc and QuadFunc */ index = shared; - if (flags & DD_TRI_SMOOTH) index |= fallback; if (flags & DD_TRI_OFFSET) index |= R128_OFFSET_BIT; - if (flags & DD_TRI_LIGHT_TWOSIDE) index |= R128_TWOSIDE_BIT; + if (flags & DD_TRI_SMOOTH) index |= fallback; if (flags & DD_TRI_UNFILLED) index |= fallback; if (flags & DD_TRI_STIPPLE) index |= fallback; 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 0980f2791..4a7a0736e 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_tris.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tris.h @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -39,35 +39,20 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #include "r128_vb.h" -#define R128_ANTIALIAS_BIT 0x00 /* ignored for now, no fallback */ #define R128_FLAT_BIT 0x01 #define R128_OFFSET_BIT 0x02 #define R128_TWOSIDE_BIT 0x04 -#define R128_NODRAW_BIT 0x08 -#define R128_FALLBACK_BIT 0x10 -#define R128_FEEDBACK_BIT 0x20 -#define R128_SELECT_BIT 0x40 -#define R128_POINT_PARAM_BIT 0x80 /* not needed? */ - -extern void r128DrawTriangleVB(r128ContextPtr r128ctx, - r128_vertex *v0, - r128_vertex *v1, - r128_vertex *v2); -extern void r128DrawLineVB(r128ContextPtr r128ctx, - r128_vertex *tmp0, r128_vertex *tmp1, - float width); -extern void r128DrawPointVB(r128ContextPtr r128ctx, - r128_vertex *tmp, float size); - -extern void r128DrawTriangle(r128ContextPtr r128ctx, - r128_vertex *v0, - r128_vertex *v1, - r128_vertex *v2); -extern void r128DrawLine(r128ContextPtr r128ctx, - r128_vertex *tmp0, r128_vertex *tmp1, - float width); -extern void r128DrawPoint(r128ContextPtr r128ctx, - r128_vertex *tmp, float size); +#define R128_FALLBACK_BIT 0x08 + +extern __inline void r128DrawTriangleVB(r128ContextPtr r128ctx, + r128Vertex *v0, + r128Vertex *v1, + r128Vertex *v2); +extern __inline void r128DrawLineVB(r128ContextPtr r128ctx, + r128Vertex *tmp0, r128Vertex *tmp1, + float width); +extern __inline void r128DrawPointVB(r128ContextPtr r128ctx, + r128Vertex *tmp, float size); extern void r128ChooseRenderState(GLcontext *ctx); extern void r128TriangleFuncsInit(void); diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h b/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h index 833bd832a..51fc9acfb 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_tritmp.h @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -43,63 +43,60 @@ static void TAG(triangle)(GLcontext *ctx, GLuint pv) { r128ContextPtr r128ctx = R128_CONTEXT(ctx); + int vertsize = r128ctx->vertsize; + CARD32 *vb = r128AllocVertexDwords(r128ctx, + 3 * vertsize); struct vertex_buffer *VB = ctx->VB; r128VertexPtr r128verts = R128_DRIVER_DATA(VB)->verts; - const r128_vertex *v0 = &r128verts[e0].v; - const r128_vertex *v1 = &r128verts[e1].v; - const r128_vertex *v2 = &r128verts[e2].v; + const r128Vertex *v[3]; + int i, j; #if (IND & R128_OFFSET_BIT) - GLfloat offset; + GLfloat offset = ctx->Polygon.OffsetUnits * r128ctx->depth_scale; #endif #if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT)) - int c0 = *(int *)&r128verts[pv].v.dif_argb; - int c1 = c0; - int c2 = c0; -#endif + int c[3]; -#if (IND & R128_OFFSET_BIT) - switch (ctx->Visual->DepthBits) { - case 16: offset = ctx->Polygon.OffsetUnits / 65536.0; break; - case 24: offset = ctx->Polygon.OffsetUnits / 16777216.0; break; - case 32: offset = ctx->Polygon.OffsetUnits / 4294967296.0; break; - default: offset = ctx->Polygon.OffsetUnits / 65536.0; break; - } + c[0] = c[1] = c[2] = *(int *)&r128verts[pv].vert1.dif_argb; #endif -#if (IND & (R128_TWOSIDE_BIT | R128_OFFSET_BIT)) + v[0] = &r128verts[e0]; + v[1] = &r128verts[e1]; + v[2] = &r128verts[e2]; + +#if (IND & (R128_TWOSIDE_BIT | R128_OFFSET_BIT)) { - GLfloat ex = v0->x - v2->x; - GLfloat ey = v0->y - v2->y; - GLfloat fx = v1->x - v2->x; - GLfloat fy = v1->y - v2->y; - GLfloat c = ex*fy - ey*fx; - -#if (IND & R128_TWOSIDE_BIT) + GLfloat ex = v[0]->vert1.x - v[2]->vert1.x; + GLfloat ey = v[0]->vert1.y - v[2]->vert1.y; + GLfloat fx = v[1]->vert1.x - v[2]->vert1.x; + GLfloat fy = v[1]->vert1.y - v[2]->vert1.y; + GLfloat cc = ex*fy - ey*fx; + +#if (IND & R128_TWOSIDE_BIT) { - GLuint facing = (c > 0.0) ^ ctx->Polygon.FrontBit; + GLuint facing = (cc > 0.0) ^ ctx->Polygon.FrontBit; GLubyte (*vbcolor)[4] = VB->Color[facing]->data; if (IND & R128_FLAT_BIT) { - R128_COLOR((char *)&c0, vbcolor[pv]); - c2 = c1 = c0; + R128_COLOR((char *)&c[0], vbcolor[pv]); + c[2] = c[1] = c[0]; } else { - R128_COLOR((char *)&c0, vbcolor[e0]); - R128_COLOR((char *)&c1, vbcolor[e1]); - R128_COLOR((char *)&c2, vbcolor[e2]); + R128_COLOR((char *)&c[0], vbcolor[e0]); + R128_COLOR((char *)&c[1], vbcolor[e1]); + R128_COLOR((char *)&c[2], vbcolor[e2]); } } #endif - -#if (IND & R128_OFFSET_BIT) + +#if (IND & R128_OFFSET_BIT) { - if (c * c > 1e-16) { + if (cc * cc > 1e-16) { GLfloat factor = ctx->Polygon.OffsetFactor; - GLfloat ez = v0->z - v2->z; - GLfloat fz = v1->z - v2->z; + GLfloat ez = v[0]->vert1.z - v[2]->vert1.z; + GLfloat fz = v[1]->vert1.z - v[2]->vert1.z; GLfloat a = ey*fz - ez*fy; GLfloat b = ez*fx - ex*fz; - GLfloat ic = 1.0 / c; + GLfloat ic = 1.0 / cc; GLfloat ac = a * ic; GLfloat bc = b * ic; if (ac < 0.0f) ac = -ac; @@ -109,156 +106,23 @@ static void TAG(triangle)(GLcontext *ctx, } #endif } -#endif - - LOCK_HARDWARE(r128ctx); - if (r128ctx->regs.tex_cntl_c & (R128_TEXMAP_ENABLE | - R128_SEC_TEXMAP_ENABLE)) { - BEGIN_CLIP_LOOP(r128ctx); - -#if USE_RHW2 - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 34); -#else - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 31); -#endif - R128CCE(R128_FULL_VERTEX_FORMAT); - R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST | - R128_CCE_VC_CNTL_PRIM_WALK_RING | - (3 << R128_CCE_VC_CNTL_NUM_SHIFT)); - - R128CCEF(v0->x); - R128CCEF(v0->y); -#if (IND & R128_OFFSET_BIT) - R128CCEF(v0->z + offset); -#else - R128CCEF(v0->z); -#endif - R128CCEF(v0->rhw); - -#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT)) - R128CCE(c0); -#else - R128CCE(*(int *)&v0->dif_argb); -#endif - R128CCE(*(int *)&v0->spec_frgb); - - R128CCEF(v0->tu0); - R128CCEF(v0->tv0); - R128CCEF(v0->tu1); - R128CCEF(v0->tv1); -#if USE_RHW2 - R128CCEF(v0->rhw2); -#endif - - R128CCEF(v1->x); - R128CCEF(v1->y); -#if (IND & R128_OFFSET_BIT) - R128CCEF(v1->z + offset); -#else - R128CCEF(v1->z); -#endif - R128CCEF(v1->rhw); - -#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT)) - R128CCE(c1); -#else - R128CCE(*(int *)&v1->dif_argb); -#endif - R128CCE(*(int *)&v1->spec_frgb); - - R128CCEF(v1->tu0); - R128CCEF(v1->tv0); - R128CCEF(v1->tu1); - R128CCEF(v1->tv1); -#if USE_RHW2 - R128CCEF(v1->rhw2); -#endif - - R128CCEF(v2->x); - R128CCEF(v2->y); -#if (IND & R128_OFFSET_BIT) - R128CCEF(v2->z + offset); -#else - R128CCEF(v2->z); -#endif - R128CCEF(v2->rhw); - -#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT)) - R128CCE(c2); -#else - R128CCE(*(int *)&v2->dif_argb); -#endif - R128CCE(*(int *)&v2->spec_frgb); - - R128CCEF(v2->tu0); - R128CCEF(v2->tv0); - R128CCEF(v2->tu1); - R128CCEF(v2->tv1); -#if USE_RHW2 - R128CCEF(v2->rhw2); #endif - R128CCE_SUBMIT_PACKETS(); + for (j = 0 ; j < 3 ; j++, vb += vertsize) { - END_CLIP_LOOP(r128ctx); - } else { - BEGIN_CLIP_LOOP(r128ctx); + for (i = 0 ; i < vertsize ; i++) + vb[i] = v[j]->ui[i]; - R128CCE3(R128_CCE_PACKET3_3D_RNDR_GEN_PRIM, 13); - R128CCE(R128_CCE_VC_FRMT_DIFFUSE_ARGB); - R128CCE(R128_CCE_VC_CNTL_PRIM_TYPE_TRI_LIST | - R128_CCE_VC_CNTL_PRIM_WALK_RING | - (3 << R128_CCE_VC_CNTL_NUM_SHIFT)); - - R128CCEF(v0->x); - R128CCEF(v0->y); -#if (IND & R128_OFFSET_BIT) - R128CCEF(v0->z + offset); -#else - R128CCEF(v0->z); +#if (IND & (R128_FLAT_BIT|R128_TWOSIDE_BIT)) + vb[4] = c[j]; /* color is the fifth element... */ #endif - -#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT)) - R128CCE(c0); -#else - R128CCE(*(int *)&v0->dif_argb); -#endif - - R128CCEF(v1->x); - R128CCEF(v1->y); #if (IND & R128_OFFSET_BIT) - R128CCEF(v1->z + offset); -#else - R128CCEF(v1->z); + *(float *)&vb[2] = v[j]->vert1.z + offset; #endif - -#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT)) - R128CCE(c1); -#else - R128CCE(*(int *)&v1->dif_argb); -#endif - - R128CCEF(v2->x); - R128CCEF(v2->y); -#if (IND & R128_OFFSET_BIT) - R128CCEF(v2->z + offset); -#else - R128CCEF(v2->z); -#endif - -#if (IND & (R128_FLAT_BIT | R128_TWOSIDE_BIT)) - R128CCE(c2); -#else - R128CCE(*(int *)&v2->dif_argb); -#endif - - R128CCE_SUBMIT_PACKETS(); - - END_CLIP_LOOP(r128ctx); - } - UNLOCK_HARDWARE(r128ctx); + } } + static void TAG(quad)(GLcontext *ctx, GLuint v0, GLuint v1, GLuint v2, GLuint v3, GLuint pv) @@ -267,7 +131,6 @@ static void TAG(quad)(GLcontext *ctx, TAG(triangle)(ctx, v1, v2, v3, pv); } -#if ((IND & ~R128_FLAT_BIT) == 0) /* Draw a single line. Note that the device-dependent vertex data might need to be changed based on the render state. */ @@ -277,17 +140,31 @@ static void TAG(line)(GLcontext *ctx, { r128ContextPtr r128ctx = R128_CONTEXT(ctx); r128VertexPtr r128verts = R128_DRIVER_DATA(ctx->VB)->verts; - r128_vertex tmp0 = r128verts[v0].v; - r128_vertex tmp1 = r128verts[v1].v; float width = ctx->Line.Width; - if (IND & R128_FLAT_BIT) { - *(int *)&tmp1.dif_argb = - *(int *)&tmp0.dif_argb = - *(int *)&r128verts[pv].v.dif_argb; - } - - r128DrawLine(r128ctx, &tmp0, &tmp1, width); + if (IND & (R128_TWOSIDE_BIT|R128_FLAT_BIT)) { + r128Vertex tmp0 = r128verts[v0]; + r128Vertex tmp1 = r128verts[v1]; + + if (IND & R128_TWOSIDE_BIT) { + GLubyte (*vbcolor)[4] = ctx->VB->ColorPtr->data; + + if (IND & R128_FLAT_BIT) { + R128_COLOR((char *)&tmp0.vert1.dif_argb, vbcolor[pv]); + *(int *)&tmp1.vert1.dif_argb = *(int *)&tmp0.vert1.dif_argb; + } else { + R128_COLOR((char *)&tmp0.vert1.dif_argb, vbcolor[v0]); + R128_COLOR((char *)&tmp1.vert1.dif_argb, vbcolor[v1]); + } + } else { + *(int *)&tmp0.vert1.dif_argb = *(int *)&r128verts[pv].vert1.dif_argb; + *(int *)&tmp1.vert1.dif_argb = *(int *)&r128verts[pv].vert1.dif_argb; + } + + r128DrawLineVB( r128ctx, &tmp0, &tmp1, width ); + } + else + r128DrawLineVB( r128ctx, &r128verts[v0], &r128verts[v1], width ); } /* Draw a set of points. Note that the device-dependent vertex data @@ -303,24 +180,24 @@ static void TAG(points)(GLcontext *ctx, for(i = first; i <= last; i++) { if(VB->ClipMask[i] == 0) { - r128_vertex *tmp = &r128verts[i].v; - r128DrawPoint(r128ctx, tmp, size); + if (IND & R128_TWOSIDE_BIT) { + GLubyte (*vbcolor)[4] = VB->ColorPtr->data; + r128Vertex tmp0 = r128verts[i]; + R128_COLOR((char *)&tmp0.vert1.dif_argb, vbcolor[i]); + r128DrawPointVB( r128ctx, &tmp0, size ); + } else + r128DrawPointVB( r128ctx, &r128verts[i], size ); } } } -#endif - /* Initialize the table of primitives to render. */ static void TAG(init)(void) { tri_tab[IND] = TAG(triangle); quad_tab[IND] = TAG(quad); - -#if ((IND & ~R128_FLAT_BIT) == 0) line_tab[IND] = TAG(line); points_tab[IND] = TAG(points); -#endif } #undef IND diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c index f14ec21bd..eb04e4473 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_vb.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.c @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -46,37 +46,32 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #define TEX0 \ do { \ - v->v.tu0 = tc0[i][0]; \ - v->v.tv0 = tc0[i][1]; \ + v->vert1.tu0 = tc0[i][0]; \ + v->vert1.tv0 = tc0[i][1]; \ } while (0) #define TEX1 \ do { \ - v->v.tu1 = tc1[i][0]; \ - v->v.tv1 = tc1[i][1]; \ + v->vert2.tu1 = tc1[i][0]; \ + v->vert2.tv1 = tc1[i][1]; \ } while (0) #define SPC \ do { \ GLubyte *spec = &(VB->Spec[0][i][0]); \ - v->v.spec_frgb.r = spec[0]; \ - v->v.spec_frgb.g = spec[1]; \ - v->v.spec_frgb.b = spec[2]; \ + v->vert1.spec_frgb.r = spec[0]; \ + v->vert1.spec_frgb.g = spec[1]; \ + v->vert1.spec_frgb.b = spec[2]; \ } while (0) -#define FOG \ -do { \ - GLubyte *spec = &(VB->Spec[0][i][0]); \ - v->v.spec_frgb.a = spec[3]; \ -} while (0) #define COL \ do { \ GLubyte *col = &(VB->Color[0]->data[i][0]); \ - v->v.dif_argb.a = col[3]; \ - v->v.dif_argb.r = col[0]; \ - v->v.dif_argb.g = col[1]; \ - v->v.dif_argb.b = col[2]; \ + v->vert1.dif_argb.a = col[3]; \ + v->vert1.dif_argb.r = col[0]; \ + v->vert1.dif_argb.g = col[1]; \ + v->vert1.dif_argb.b = col[2]; \ } while (0) #if 1 @@ -91,9 +86,9 @@ do { \ v = &(R128_DRIVER_DATA(VB)->verts[start]); \ for (i = start; i < end; i++, v++) { \ float oow = 1.0 / tc[i][3]; \ - v->v.rhw *= tc[i][3]; \ - v->v.tu0 *= oow; \ - v->v.tv0 *= oow; \ + v->vert1.rhw *= tc[i][3]; \ + v->vert1.tu0 *= oow; \ + v->vert1.tv0 *= oow; \ } \ } \ } while (0) @@ -106,9 +101,9 @@ do { \ v = &(R128_DRIVER_DATA(VB)->verts[start]); \ for (i = start; i < end; i++, v++) { \ float oow = 1.0 / tc[i][3]; \ - v->v.rhw2 *= tc[i][3]; \ - v->v.tu1 *= oow; \ - v->v.tv1 *= oow; \ + v->vert3.rhw2 *= tc[i][3]; \ + v->vert3.tu1 *= oow; \ + v->vert3.tv1 *= oow; \ } \ } \ } while (0) @@ -121,26 +116,26 @@ do { \ #define COORD \ do { \ GLfloat *win = VB->Win.data[i]; \ - v->v.x = win[0]; \ - v->v.y = r128height - win[1]; \ - v->v.z = scale * win[2]; \ - v->v.rhw = v->v.rhw2 = win[3]; \ + v->vert3.x = win[0]; \ + v->vert3.y = r128height - win[1]; \ + v->vert3.z = scale * win[2]; \ + v->vert3.rhw = v->vert3.rhw2 = win[3]; \ } while (0) #else #define COORD \ do { \ GLfloat *win = VB->Win.data[i]; \ - v->v.x = win[0]; \ - v->v.y = r128height - win[1]; \ - v->v.z = scale * win[2]; \ - v->v.rhw = win[3]; \ + v->vert1.x = win[0]; \ + v->vert1.y = r128height - win[1]; \ + v->vert1.z = scale * win[2]; \ + v->vert1.rhw = win[3]; \ } while (0) #endif #define NOP /* Setup the r128 vertex buffer entries */ -#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,tex1_4,spec,fog) \ +#define SETUPFUNC(name,win,col,tex0,tex1,tex0_4,tex1_4,spec) \ static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \ { \ r128ContextPtr r128ctx = R128_CONTEXT(VB->ctx); \ @@ -149,23 +144,16 @@ static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \ GLfloat (*tc0)[4]; \ GLfloat (*tc1)[4]; \ GLfloat r128height = dPriv->h; \ - GLfloat scale; \ + GLfloat scale = r128ctx->depth_scale; \ int i; \ \ - (void) r128height; (void) r128ctx; \ + (void) r128height; (void) r128ctx; (void) scale; \ \ gl_import_client_data(VB, VB->ctx->RenderFlags, \ (VB->ClipOrMask \ ? VEC_WRITABLE | VEC_GOOD_STRIDE \ : VEC_GOOD_STRIDE)); \ \ - switch (VB->ctx->Visual->DepthBits) { \ - case 16: scale = 1.0 / 65536.0; break; \ - case 24: scale = 1.0 / 16777216.0; break; \ - case 32: scale = 1.0 / 4294967296.0; break; \ - default: scale = 1.0 / 65536.0; break; \ - } \ - \ tc0 = VB->TexCoordPtr[0]->data; \ tc1 = VB->TexCoordPtr[1]->data; \ \ @@ -176,7 +164,6 @@ static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \ win; \ col; \ spec; \ - fog; \ tex0; \ tex1; \ } \ @@ -185,7 +172,6 @@ static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \ if (VB->ClipMask[i] == 0) { \ win; \ spec; \ - fog; \ tex0; \ tex1; \ } \ @@ -196,52 +182,29 @@ static void name(struct vertex_buffer *VB, GLuint start, GLuint end) \ } -SETUPFUNC(rs_wt0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP, NOP) -SETUPFUNC(rs_wt1, COORD, NOP, NOP, TEX1, NOP, TEX1_4, NOP, NOP) -SETUPFUNC(rs_wt0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP) -SETUPFUNC(rs_wft0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP, FOG) -SETUPFUNC(rs_wft1, COORD, NOP, NOP, TEX1, NOP, TEX1_4, NOP, FOG) -SETUPFUNC(rs_wft0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG) -SETUPFUNC(rs_wg, COORD, COL, NOP, NOP, NOP, NOP, NOP, NOP) -SETUPFUNC(rs_wgs, COORD, COL, NOP, NOP, NOP, NOP, SPC, NOP) -SETUPFUNC(rs_wgt0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP, NOP) -SETUPFUNC(rs_wgt1, COORD, COL, NOP, TEX1, NOP, TEX1_4, NOP, NOP) -SETUPFUNC(rs_wgt0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP) -SETUPFUNC(rs_wgst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC, NOP) -SETUPFUNC(rs_wgst1, COORD, COL, NOP, TEX1, NOP, TEX1_4, SPC, NOP) -SETUPFUNC(rs_wgst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP) -SETUPFUNC(rs_wgf, COORD, COL, NOP, NOP, NOP, NOP, NOP, FOG) -SETUPFUNC(rs_wgfs, COORD, COL, NOP, NOP, NOP, NOP, SPC, FOG) -SETUPFUNC(rs_wgft0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP, FOG) -SETUPFUNC(rs_wgft1, COORD, COL, NOP, TEX1, NOP, TEX1_4, NOP, FOG) -SETUPFUNC(rs_wgft0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG) -SETUPFUNC(rs_wgfst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC, FOG) -SETUPFUNC(rs_wgfst1 , COORD, COL, NOP, TEX1, NOP, TEX1_4, SPC, FOG) -SETUPFUNC(rs_wgfst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG) - -SETUPFUNC(rs_t0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP, NOP) -SETUPFUNC(rs_t1, NOP, NOP, NOP, TEX1, NOP, TEX1_4, NOP, NOP) -SETUPFUNC(rs_t0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP) -SETUPFUNC(rs_f, NOP, NOP, NOP, NOP, NOP, NOP, NOP, FOG) -SETUPFUNC(rs_ft0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP, FOG) -SETUPFUNC(rs_ft1, NOP, NOP, NOP, TEX1, NOP, TEX1_4, NOP, FOG) -SETUPFUNC(rs_ft0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG) -SETUPFUNC(rs_g, NOP, COL, NOP, NOP, NOP, NOP, NOP, NOP) -SETUPFUNC(rs_gs, NOP, COL, NOP, NOP, NOP, NOP, SPC, NOP) -SETUPFUNC(rs_gt0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP, NOP) -SETUPFUNC(rs_gt1, NOP, COL, NOP, TEX1, NOP, TEX1_4, NOP, NOP) -SETUPFUNC(rs_gt0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, NOP) -SETUPFUNC(rs_gst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC, NOP) -SETUPFUNC(rs_gst1, NOP, COL, NOP, TEX1, NOP, TEX1_4, SPC, NOP) -SETUPFUNC(rs_gst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, NOP) -SETUPFUNC(rs_gf, NOP, COL, NOP, NOP, NOP, NOP, NOP, FOG) -SETUPFUNC(rs_gfs, NOP, COL, NOP, NOP, NOP, NOP, SPC, FOG) -SETUPFUNC(rs_gft0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP, FOG) -SETUPFUNC(rs_gft1, NOP, COL, NOP, TEX1, NOP, TEX1_4, NOP, FOG) -SETUPFUNC(rs_gft0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP, FOG) -SETUPFUNC(rs_gfst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC, FOG) -SETUPFUNC(rs_gfst1, NOP, COL, NOP, TEX1, NOP, TEX1_4, SPC, FOG) -SETUPFUNC(rs_gfst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC, FOG) +SETUPFUNC(rs_wt0, COORD, NOP, TEX0, NOP, TEX0_4, NOP, NOP) +SETUPFUNC(rs_wt1, COORD, NOP, NOP, TEX1, NOP, TEX1_4, NOP) +SETUPFUNC(rs_wt0t1, COORD, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP) +SETUPFUNC(rs_wg, COORD, COL, NOP, NOP, NOP, NOP, NOP) +SETUPFUNC(rs_wgs, COORD, COL, NOP, NOP, NOP, NOP, SPC) +SETUPFUNC(rs_wgt0, COORD, COL, TEX0, NOP, TEX0_4, NOP, NOP) +SETUPFUNC(rs_wgt1, COORD, COL, NOP, TEX1, NOP, TEX1_4, NOP) +SETUPFUNC(rs_wgt0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP) +SETUPFUNC(rs_wgst0, COORD, COL, TEX0, NOP, TEX0_4, NOP, SPC) +SETUPFUNC(rs_wgst1, COORD, COL, NOP, TEX1, NOP, TEX1_4, SPC) +SETUPFUNC(rs_wgst0t1, COORD, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC) + +SETUPFUNC(rs_t0, NOP, NOP, TEX0, NOP, TEX0_4, NOP, NOP) +SETUPFUNC(rs_t1, NOP, NOP, NOP, TEX1, NOP, TEX1_4, NOP) +SETUPFUNC(rs_t0t1, NOP, NOP, TEX0, TEX1, TEX0_4, TEX1_4, NOP) +SETUPFUNC(rs_g, NOP, COL, NOP, NOP, NOP, NOP, NOP) +SETUPFUNC(rs_gs, NOP, COL, NOP, NOP, NOP, NOP, SPC) +SETUPFUNC(rs_gt0, NOP, COL, TEX0, NOP, TEX0_4, NOP, NOP) +SETUPFUNC(rs_gt1, NOP, COL, NOP, TEX1, NOP, TEX1_4, NOP) +SETUPFUNC(rs_gt0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, NOP) +SETUPFUNC(rs_gst0, NOP, COL, TEX0, NOP, TEX0_4, NOP, SPC) +SETUPFUNC(rs_gst1, NOP, COL, NOP, TEX1, NOP, TEX1_4, SPC) +SETUPFUNC(rs_gst0t1, NOP, COL, TEX0, TEX1, TEX0_4, TEX1_4, SPC) static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end) { @@ -249,22 +212,20 @@ static void rs_invalid(struct vertex_buffer *VB, GLuint start, GLuint end) } typedef void (*setupFunc)(struct vertex_buffer *, GLuint, GLuint); -static setupFunc setup_func[0x80]; +static setupFunc setup_func[0x20]; /* Initialize the table of vertex buffer setup functions */ void r128SetupInit(void) { int i; - for (i = 0; i < 0x80; i++) setup_func[i] = rs_invalid; + for (i = 0; i < 0x20; i++) setup_func[i] = rs_invalid; /* Funcs to build vertices from scratch */ setup_func[R128_WIN_BIT|R128_TEX0_BIT] = rs_wt0; setup_func[R128_WIN_BIT|R128_TEX1_BIT] = rs_wt1; setup_func[R128_WIN_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wt0t1; - setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_wft0; - setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX1_BIT] = rs_wft1; - setup_func[R128_WIN_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wft0t1; + setup_func[R128_WIN_BIT|R128_RGBA_BIT] = rs_wg; setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT] = rs_wgs; setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_TEX0_BIT] = rs_wgt0; @@ -273,23 +234,12 @@ void r128SetupInit(void) setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgst0; setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_wgst1; setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgst0t1; - setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT] = rs_wgf; - setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT] = rs_wgfs; - setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_wgft0; - setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX1_BIT] = rs_wgft1; - setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgft0t1; - setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_wgfst0; - setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_wgfst1; - setup_func[R128_WIN_BIT|R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_wgfst0t1; + /* Funcs to repair vertices */ setup_func[R128_TEX0_BIT] = rs_t0; setup_func[R128_TEX1_BIT] = rs_t1; setup_func[R128_TEX0_BIT|R128_TEX1_BIT] = rs_t0t1; - setup_func[R128_FOG_BIT] = rs_f; - setup_func[R128_FOG_BIT|R128_TEX0_BIT] = rs_ft0; - setup_func[R128_FOG_BIT|R128_TEX1_BIT] = rs_ft1; - setup_func[R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_ft0t1; setup_func[R128_RGBA_BIT] = rs_g; setup_func[R128_RGBA_BIT|R128_SPEC_BIT] = rs_gs; setup_func[R128_RGBA_BIT|R128_TEX0_BIT] = rs_gt0; @@ -298,14 +248,6 @@ void r128SetupInit(void) setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gst0; setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_gst1; setup_func[R128_RGBA_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gst0t1; - setup_func[R128_RGBA_BIT|R128_FOG_BIT] = rs_gf; - setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT] = rs_gfs; - setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT] = rs_gft0; - setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX1_BIT] = rs_gft1; - setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gft0t1; - setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT] = rs_gfst0; - setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX1_BIT] = rs_gfst1; - setup_func[R128_RGBA_BIT|R128_FOG_BIT|R128_SPEC_BIT|R128_TEX0_BIT|R128_TEX1_BIT] = rs_gfst0t1; } /* Initialize the vertex buffer setup functions based on the current @@ -315,22 +257,33 @@ void r128ChooseRasterSetupFunc(GLcontext *ctx) r128ContextPtr r128ctx = R128_CONTEXT(ctx); int funcIndex = R128_WIN_BIT | R128_RGBA_BIT; - if (ctx->Texture.Enabled & 0xf) { + r128ctx->vertsize = 8; + r128ctx->vc_format = R128_TEX0_VERTEX_FORMAT; + r128ctx->multitex = 0; + + if (ctx->Texture.Enabled & ENABLE_TEX0) { if (ctx->Texture.Unit[0].EnvMode == GL_REPLACE) funcIndex &= ~R128_RGBA_BIT; funcIndex |= R128_TEX0_BIT; } - if (ctx->Texture.Enabled & 0xf0) + if (ctx->Texture.Enabled & ENABLE_TEX1) { + /* GTH: we should really only enable the second texture unit + * when we're doing true multitexturing. I guess there aren't + * that many cases where apps will only bind a texture to the + * second texture unit, but it would definitely be a performance + * win in those cases. + */ + r128ctx->vertsize = 10; + r128ctx->vc_format = R128_TEX1_VERTEX_FORMAT; + r128ctx->multitex = 1; funcIndex |= R128_TEX1_BIT; + } /* FIXME: Verify this works properly */ if (ctx->Light.Model.ColorControl == GL_SEPARATE_SPECULAR_COLOR) funcIndex |= R128_SPEC_BIT; - if (ctx->FogMode == FOG_FRAGMENT) - funcIndex |= R128_FOG_BIT; - r128ctx->SetupIndex = funcIndex; ctx->Driver.RasterSetup = setup_func[funcIndex]; } @@ -351,6 +304,7 @@ void r128CheckPartialRasterSetup(GLcontext *ctx, r128ctx->SetupDone = tmp; } + /* Update the vertex buffer entries, if necessary */ void r128PartialRasterSetup(struct vertex_buffer *VB) { @@ -361,22 +315,18 @@ void r128PartialRasterSetup(struct vertex_buffer *VB) if (new & VERT_WIN) { new = available; - index |= R128_WIN_BIT | R128_FOG_BIT; + index |= R128_WIN_BIT; } if (new & VERT_RGBA) index |= R128_RGBA_BIT | R128_SPEC_BIT; if (new & VERT_TEX0_ANY) index |= R128_TEX0_BIT; if (new & VERT_TEX1_ANY) index |= R128_TEX1_BIT; -#if 0 - /* FIXME */ - if (new & VERT_FOG_COORD) index |= R128_FOG_BIT; -#endif r128ctx->SetupDone &= ~index; index &= r128ctx->SetupIndex; r128ctx->SetupDone |= index; - if (index) setup_func[index & ~R128_ALPHA_BIT](VB, VB->Start, VB->Count); + if (index) setup_func[index](VB, VB->Start, VB->Count); } /* Perform the raster setup for the fast path, if using CVA */ 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 4f7c11d7f..f2244b687 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_vb.h +++ b/xc/lib/GL/mesa/src/drv/r128/r128_vb.h @@ -2,7 +2,7 @@ /************************************************************************** Copyright 1999, 2000 ATI Technologies Inc. and Precision Insight, Inc., - Cedar Park, Texas. + Cedar Park, Texas. All Rights Reserved. Permission is hereby granted, free of charge, to any person obtaining a @@ -37,8 +37,6 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifdef GLX_DIRECT_RENDERING -#define USE_RHW2 0 - /* FIXME: This is endian-specific */ typedef struct { GLubyte b; @@ -47,6 +45,37 @@ typedef struct { GLubyte a; } r128Color; +/* Single texture vertex, single x86 cache line. + * + * GTH: This is in use now. + */ +typedef struct { + GLfloat x, y, z; /* Coordinates in screen space */ + GLfloat rhw; /* Reciprocal homogeneous w */ + r128Color dif_argb; /* Diffuse color */ + r128Color spec_frgb; /* Specular color (alpha is fog) */ + GLfloat tu0, tv0; /* Texture 0 coordinates */ +} r128_vertex1; + +/* The only vertex format in current use, but unsatisfactory for two + * reasons: + * - Not possible to implement fully conformant rendering + * with this format (projective multitexturing), + * - Performance is lower with this vertex for single-texture + * geometry, as the vertex is unnecessarily larger than + * a cacheline. + * + * Switching to single-texture vertices can be accomplished in state + * management, and is relatively trivial. Switching to the rhw2 + * format is data-dependent (are there any glTexCoord4f's in the + * current buffer). One option is to switch between single-texture + * and rhw2 vertex formats only on the standard path. + * + * The fastpath never requires the rhw2 format, as it already makes + * the data-dependent checks. + * + * GTH: This is fixed. + */ typedef struct { GLfloat x, y, z; /* Coordinates in screen space */ GLfloat rhw; /* Reciprocal homogeneous w */ @@ -54,68 +83,57 @@ typedef struct { r128Color spec_frgb; /* Specular color (alpha is fog) */ GLfloat tu0, tv0; /* Texture 0 coordinates */ GLfloat tu1, tv1; /* Texture 1 coordinates */ -#if USE_RHW2 - GLfloat rhw2; /* Reciprocal homogeneous w */ -#endif -} r128_vertex; +} r128_vertex2; + +/* Need to be slightly clever about flushing vertex buffers in order + * to use rhw2 only on demand. + * + * GTH: This can be used now. + */ +typedef struct { + GLfloat x, y, z; /* Coordinates in screen space */ + GLfloat rhw; /* Reciprocal homogeneous w */ + r128Color dif_argb; /* Diffuse color */ + r128Color spec_frgb; /* Specular color (alpha is fog) */ + GLfloat tu0, tv0; /* Texture 0 coordinates */ + GLfloat tu1, tv1; /* Texture 1 coordinates */ + GLfloat rhw2; /* Reciprocal homogeneous w2 */ +} r128_vertex2_rhw2; -#if USE_RHW2 /* Format of vertices in r128_vertex struct */ -#define R128_FULL_VERTEX_FORMAT \ +#define R128_TEX0_VERTEX_FORMAT \ R128_CCE_VC_FRMT_RHW | \ R128_CCE_VC_FRMT_DIFFUSE_ARGB | \ R128_CCE_VC_FRMT_SPEC_FRGB | \ - R128_CCE_VC_FRMT_S_T | \ - R128_CCE_VC_FRMT_S2_T2 | \ - R128_CCE_VC_FRMT_RHW2 + R128_CCE_VC_FRMT_S_T -/* Send a single vertex to the ring buffer */ -#define R128CCE_SEND_VERTEX(v) \ - do { \ - R128CCEF((v)->x); \ - R128CCEF((v)->y); \ - R128CCEF((v)->z); \ - R128CCEF((v)->rhw); \ - R128CCE(*(int *)&(v)->dif_argb); \ - R128CCE(*(int *)&(v)->spec_frgb); \ - R128CCEF((v)->tu0); \ - R128CCEF((v)->tv0); \ - R128CCEF((v)->tu1); \ - R128CCEF((v)->tv1); \ - R128CCEF((v)->rhw2); \ - } while (0) - -#else /* !USE_RHW2 */ - -/* Format of vertices in r128_vertex struct */ -#define R128_FULL_VERTEX_FORMAT \ +#define R128_TEX1_VERTEX_FORMAT \ R128_CCE_VC_FRMT_RHW | \ R128_CCE_VC_FRMT_DIFFUSE_ARGB | \ R128_CCE_VC_FRMT_SPEC_FRGB | \ R128_CCE_VC_FRMT_S_T | \ R128_CCE_VC_FRMT_S2_T2 -/* Send a single vertex to the ring buffer */ -#define R128CCE_SEND_VERTEX(v) \ - do { \ - R128CCEF((v)->x); \ - R128CCEF((v)->y); \ - R128CCEF((v)->z); \ - R128CCEF((v)->rhw); \ - R128CCE(*(int *)&(v)->dif_argb); \ - R128CCE(*(int *)&(v)->spec_frgb); \ - R128CCEF((v)->tu0); \ - R128CCEF((v)->tv0); \ - R128CCEF((v)->tu1); \ - R128CCEF((v)->tv1); \ - } while (0) -#endif +#define R128_PROJ_TEX1_VERTEX_FORMAT \ + R128_CCE_VC_FRMT_RHW | \ + R128_CCE_VC_FRMT_DIFFUSE_ARGB | \ + R128_CCE_VC_FRMT_SPEC_FRGB | \ + R128_CCE_VC_FRMT_S_T | \ + R128_CCE_VC_FRMT_S2_T2 | \ + R128_CCE_VC_FRMT_RHW2 + /* FIXME: We currently only have assembly for 16-stride vertices */ -typedef union { - r128_vertex v; - float f[16]; -} r128Vertex, *r128VertexPtr; +union r128_vertex_t { + r128_vertex1 vert1; + r128_vertex2 vert2; + r128_vertex2_rhw2 vert3; + float f[16]; + CARD32 ui[16]; +}; + +typedef union r128_vertex_t r128Vertex; +typedef union r128_vertex_t *r128VertexPtr; /* Vertex buffer for use when on the fast path */ typedef struct { @@ -129,12 +147,10 @@ typedef struct { #define R128_DRIVER_DATA(vb) ((r128VertexBufferPtr)((vb)->driver_data)) #define R128_SPEC_BIT 0x01 -#define R128_FOG_BIT 0x02 -#define R128_ALPHA_BIT 0x04 /* GL_BLEND, not used */ -#define R128_TEX1_BIT 0x08 -#define R128_TEX0_BIT 0x10 -#define R128_RGBA_BIT 0x20 -#define R128_WIN_BIT 0x40 +#define R128_TEX1_BIT 0x02 +#define R128_TEX0_BIT 0x04 +#define R128_RGBA_BIT 0x08 +#define R128_WIN_BIT 0x10 extern void r128SetupInit(void); extern void r128ChooseRasterSetupFunc(GLcontext *ctx); diff --git a/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c index ff4f9df63..aae13df65 100644 --- a/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c +++ b/xc/lib/GL/mesa/src/drv/r128/r128_xmesa.c @@ -49,19 +49,17 @@ USE OR OTHER DEALINGS IN THE SOFTWARE. #ifndef R128_DEBUG_FLAGS int R128_DEBUG_FLAGS = (0 -#if 0 - | DEBUG_ALWAYS_SYNC - | DEBUG_VERBOSE_CCE - | DEBUG_VERBOSE_OUTREG - | DEBUG_VERBOSE_MSG - | DEBUG_NO_OUTRING - | DEBUG_NO_OUTREG - | DEBUG_VERBOSE_API - | DEBUG_VERBOSE_2D - | DEBUG_VERBOSE_DRI - | DEBUG_VALIDATE_RING - | DEBUG_VERBOSE_IOCTL -#endif +/* | DEBUG_ALWAYS_SYNC */ +/* | DEBUG_VERBOSE_CCE */ +/* | DEBUG_VERBOSE_OUTREG */ +/* | DEBUG_VERBOSE_MSG */ +/* | DEBUG_NO_OUTRING */ +/* | DEBUG_NO_OUTREG */ +/* | DEBUG_VERBOSE_API */ +/* | DEBUG_VERBOSE_2D */ +/* | DEBUG_VERBOSE_DRI */ +/* | DEBUG_VALIDATE_RING */ +/* | DEBUG_VERBOSE_IOCTL */ ); #endif @@ -77,7 +75,10 @@ static r128ContextPtr r128Context = NULL; GLboolean XMesaInitDriver(__DRIscreenPrivate *sPriv) { sPriv->private = (void *)r128CreateScreen(sPriv); - if (!sPriv->private) return GL_FALSE; + if (!sPriv->private) { + r128DestroyScreen(sPriv); + return GL_FALSE; + } return GL_TRUE; } 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 c8c5581da..c71af2cc6 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 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -62,7 +62,7 @@ typedef unsigned int drm_context_t; typedef unsigned int drm_drawable_t; typedef unsigned int drm_magic_t; -/* Warning: If you change this structure, make sure you change +/* Warning: If you change this structure, make sure you change * XF86DRIClipRectRec in the server as well */ typedef struct drm_clip_rect { @@ -358,7 +358,7 @@ typedef struct drm_agp_info { #define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t) #define DRM_IOCTL_R128_RESET DRM_IO( 0x41) #define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42) -#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43) +#define DRM_IOCTL_R128_IDLE DRM_IO( 0x43) #define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t) #define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c index 860c41885..dd416db17 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c +++ b/xc/programs/Xserver/hw/xfree86/os-support/linux/drm/kernel/r128_dma.c @@ -10,11 +10,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -22,9 +22,9 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Authors: Kevin E. Martin <kevin@precisioninsight.com> - * + * * $XFree86$ * */ @@ -88,6 +88,20 @@ static void r128_flush_write_combine(void) "pop %%eax" : /* no outputs */ : /* no inputs */ ); } +static void r128_status(drm_device_t *dev) +{ + drm_r128_private_t *dev_priv = dev->dev_private; + + printk("GUI_STAT = 0x%08x\n", + (unsigned int)R128_READ(R128_GUI_STAT)); + printk("PM4_STAT = 0x%08x\n", + (unsigned int)R128_READ(R128_PM4_STAT)); + printk("PM4_BUFFER_DL_WPTR = 0x%08x\n", + (unsigned int)R128_READ(R128_PM4_BUFFER_DL_WPTR)); + printk("PM4_BUFFER_DL_RPTR = 0x%08x\n", + (unsigned int)R128_READ(R128_PM4_BUFFER_DL_RPTR)); +} + static int r128_do_cleanup_cce(drm_device_t *dev) { if (dev->dev_private) { @@ -828,6 +842,7 @@ static drm_buf_t *r128_freelist_get(drm_device_t *dev) udelay(1); } + r128_status(dev); return NULL; } 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 53ac8ce34..e5a85af90 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 @@ -10,11 +10,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -22,10 +22,10 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Authors: Rickard E. (Rik) Faith <faith@precisioninsight.com> * Kevin E. Martin <kevin@precisioninsight.com> - * + * * $XFree86$ * */ @@ -108,7 +108,7 @@ static drm_ioctl_desc_t r128_ioctls[] = { [DRM_IOCTL_NR(DRM_IOCTL_R128_RESET)] = { r128_eng_reset, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_R128_FLUSH)] = { r128_eng_flush, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_R128_PACKET)] = { r128_submit_pkt, 1, 0 }, - [DRM_IOCTL_NR(DRM_IOCTL_R128_CCEIDL)] = { r128_cce_idle, 1, 0 }, + [DRM_IOCTL_NR(DRM_IOCTL_R128_IDLE)] = { r128_cce_idle, 1, 0 }, [DRM_IOCTL_NR(DRM_IOCTL_R128_VERTEX)] = { r128_vertex_buf, 1, 0 }, }; #define R128_IOCTL_COUNT DRM_ARRAY_SIZE(r128_ioctls) @@ -144,7 +144,7 @@ void cleanup_module(void) * * This is not currently supported, since it requires changes to * linux/init/main.c. */ - + void __init r128_setup(char *str, int *ints) { @@ -159,7 +159,7 @@ void __init r128_setup(char *str, int *ints) static int r128_setup(drm_device_t *dev) { int i; - + atomic_set(&dev->ioctl_count, 0); atomic_set(&dev->vma_count, 0); dev->buf_use = 0; @@ -202,7 +202,7 @@ static int r128_setup(drm_device_t *dev) dev->ctx_start = 0; dev->lck_start = 0; - + dev->buf_rp = dev->buf; dev->buf_wp = dev->buf; dev->buf_end = dev->buf + DRM_BSZ; @@ -211,15 +211,15 @@ static int r128_setup(drm_device_t *dev) init_waitqueue_head(&dev->buf_writers); r128_res_ctx.handle=-1; - + DRM_DEBUG("\n"); - + /* The kernel's context could be created here, but is now created in drm_dma_enqueue. This is more resource-efficient for hardware that does not do DMA, but may mean that drm_select_queue fails between the time the interrupt is initialized and the time the queues are initialized. */ - + return 0; } @@ -235,12 +235,12 @@ static int r128_takedown(drm_device_t *dev) down(&dev->struct_sem); del_timer(&dev->timer); - + if (dev->devname) { drm_free(dev->devname, strlen(dev->devname)+1, DRM_MEM_DRIVER); dev->devname = NULL; } - + if (dev->unique) { drm_free(dev->unique, strlen(dev->unique)+1, DRM_MEM_DRIVER); dev->unique = NULL; @@ -260,7 +260,7 @@ static int r128_takedown(drm_device_t *dev) if (dev->agp) { drm_agp_mem_t *entry; drm_agp_mem_t *nexte; - + /* Remove AGP resources, but leave dev->agp intact until r128_cleanup is called. */ for (entry = dev->agp->memory; entry; entry = nexte) { @@ -270,15 +270,15 @@ static int r128_takedown(drm_device_t *dev) drm_free(entry, sizeof(*entry), DRM_MEM_AGPLISTS); } dev->agp->memory = NULL; - + if (dev->agp->acquired && drm_agp.release) (*drm_agp.release)(); - + dev->agp->acquired = 0; dev->agp->enabled = 0; } #endif - + /* Clear vma list (only built for debugging) */ if (dev->vmalist) { for (vma = dev->vmalist; vma; vma = vma_next) { @@ -287,7 +287,7 @@ static int r128_takedown(drm_device_t *dev) } dev->vmalist = NULL; } - + /* Clear map area and mtrr information */ if (dev->maplist) { for (i = 0; i < dev->map_count; i++) { @@ -325,7 +325,7 @@ static int r128_takedown(drm_device_t *dev) dev->maplist = NULL; dev->map_count = 0; } - + drm_dma_takedown(dev); dev->queue_count = 0; @@ -335,7 +335,7 @@ static int r128_takedown(drm_device_t *dev) wake_up_interruptible(&dev->lock.lock_queue); } up(&dev->struct_sem); - + return 0; } @@ -352,7 +352,7 @@ int r128_init(void) memset((void *)dev, 0, sizeof(*dev)); dev->count_lock = SPIN_LOCK_UNLOCKED; sema_init(&dev->struct_sem, 1); - + #ifdef MODULE drm_parse_options(r128); #endif @@ -404,7 +404,7 @@ void r128_cleanup(void) drm_device_t *dev = &r128_device; DRM_DEBUG("\n"); - + drm_proc_cleanup(); if (misc_deregister(&r128_misc)) { DRM_ERROR("Cannot unload module\n"); @@ -460,7 +460,7 @@ int r128_open(struct inode *inode, struct file *filp) { drm_device_t *dev = &r128_device; int retcode = 0; - + DRM_DEBUG("open_count = %d\n", dev->open_count); if (!(retcode = drm_open_helper(inode, filp, dev))) { MOD_INC_USE_COUNT; @@ -517,7 +517,7 @@ int r128_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, atomic_inc(&dev->ioctl_count); atomic_inc(&dev->total_ioctl); ++priv->ioctl_count; - + DRM_DEBUG("pid = %d, cmd = 0x%02x, nr = 0x%02x, dev 0x%x, auth = %d\n", current->pid, cmd, nr, dev->device, priv->authenticated); @@ -537,7 +537,7 @@ int r128_ioctl(struct inode *inode, struct file *filp, unsigned int cmd, retcode = (func)(inode, filp, cmd, arg); } } - + atomic_dec(&dev->ioctl_count); return retcode; } @@ -574,7 +574,7 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, if (lock.context < 0 || lock.context >= dev->queue_count) return -EINVAL; #endif - + if (!ret) { #if 0 if (_DRM_LOCKING_CONTEXT(dev->lock.hw_lock->lock) @@ -586,7 +586,7 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, /* Can't take lock if we just had it and there is contention. */ DRM_DEBUG("%d (pid %d) delayed j=%d dev=%d jiffies=%d\n", - lock.context, current->pid, j, + lock.context, current->pid, j, dev->lock.lock_time, jiffies); current->state = TASK_INTERRUPTIBLE; current->policy |= SCHED_YIELD; @@ -609,7 +609,7 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, atomic_inc(&dev->total_locks); break; /* Got lock */ } - + /* Contention */ atomic_inc(&dev->total_sleeps); current->state = TASK_INTERRUPTIBLE; @@ -665,7 +665,7 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, } #if 0 - DRM_ERROR("pid = %5d, old counter = %5ld\n", + DRM_ERROR("pid = %5d, old counter = %5ld\n", current->pid, current->counter); #endif if (lock.context != r128_res_ctx.handle) { @@ -683,7 +683,7 @@ int r128_lock(struct inode *inode, struct file *filp, unsigned int cmd, #if DRM_DMA_HISTOGRAM atomic_inc(&dev->histo.lacq[drm_histogram_slot(get_cycles() - start)]); #endif - + return ret; } @@ -696,7 +696,7 @@ int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd, drm_lock_t lock; copy_from_user_ret(&lock, (drm_lock_t *)arg, sizeof(lock), -EFAULT); - + if (lock.context == DRM_KERNEL_CONTEXT) { DRM_ERROR("Process %d using kernel context %d\n", current->pid, lock.context); @@ -732,6 +732,6 @@ int r128_unlock(struct inode *inode, struct file *filp, unsigned int cmd, current->state = TASK_INTERRUPTIBLE; schedule_timeout(10); #endif - + 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 99f267f3d..e08a3185d 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 @@ -10,11 +10,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -22,11 +22,11 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Author: Kevin E. Martin <kevin@precisioninsight.com> - * + * * $XFree86$ - * + * */ #ifdef XFree86Server @@ -79,7 +79,7 @@ extern int xf86RemoveSIGIOHandler(int fd); int drmR128InitCCE(int fd, drmR128Init *info) { drm_r128_init_t init; - + memset(&init, 0, sizeof(drm_r128_init_t)); init.func = R128_INIT_CCE; @@ -131,14 +131,14 @@ int drmR128EngineFlush(int fd) return 0; } -int drmR128CCEWaitForIdle(int fd) +int drmR128WaitForIdle(int fd) { - if (ioctl(fd, DRM_IOCTL_R128_CCEIDL, NULL)) return -errno; + if (ioctl(fd, DRM_IOCTL_R128_IDLE, NULL)) return -errno; return 0; } -int drmR128SubmitPackets(int fd, CARD32 *buffer, int *count, int flags) +int drmR128SubmitPacket(int fd, CARD32 *buffer, int *count, int flags) { drm_r128_packet_t packet; int ret; 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 c8c5581da..c71af2cc6 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 @@ -11,11 +11,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -62,7 +62,7 @@ typedef unsigned int drm_context_t; typedef unsigned int drm_drawable_t; typedef unsigned int drm_magic_t; -/* Warning: If you change this structure, make sure you change +/* Warning: If you change this structure, make sure you change * XF86DRIClipRectRec in the server as well */ typedef struct drm_clip_rect { @@ -358,7 +358,7 @@ typedef struct drm_agp_info { #define DRM_IOCTL_R128_INIT DRM_IOW( 0x40, drm_r128_init_t) #define DRM_IOCTL_R128_RESET DRM_IO( 0x41) #define DRM_IOCTL_R128_FLUSH DRM_IO( 0x42) -#define DRM_IOCTL_R128_CCEIDL DRM_IO( 0x43) +#define DRM_IOCTL_R128_IDLE DRM_IO( 0x43) #define DRM_IOCTL_R128_PACKET DRM_IOW( 0x44, drm_r128_packet_t) #define DRM_IOCTL_R128_VERTEX DRM_IOW( 0x45, drm_r128_vertex_t) diff --git a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h index 46898a53c..dd430ed87 100644 --- a/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h +++ b/xc/programs/Xserver/hw/xfree86/os-support/xf86drmR128.h @@ -10,11 +10,11 @@ * the rights to use, copy, modify, merge, publish, distribute, sublicense, * and/or sell copies of the Software, and to permit persons to whom the * Software is furnished to do so, subject to the following conditions: - * + * * The above copyright notice and this permission notice (including the next * paragraph) shall be included in all copies or substantial portions of the * Software. - * + * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL @@ -22,11 +22,11 @@ * OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, * ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER * DEALINGS IN THE SOFTWARE. - * + * * Author: Kevin E. Martin <kevin@precisioninsight.com> * * $XFree86$ - * + * */ #ifndef _XF86DRI_R128_H_ @@ -70,8 +70,8 @@ extern int drmR128InitCCE(int fd, drmR128Init *info); extern int drmR128CleanupCCE(int fd); extern int drmR128EngineReset(int fd); extern int drmR128EngineFlush(int fd); -extern int drmR128CCEWaitForIdle(int fd); -extern int drmR128SubmitPackets(int fd, CARD32 *buffer, int *count, int flags); +extern int drmR128WaitForIdle(int fd); +extern int drmR128SubmitPacket(int fd, CARD32 *buffer, int *count, int flags); extern int drmR128GetVertexBuffers(int fd, int count, int *indices, int *sizes); extern int drmR128FlushVertexBuffers(int fd, int count, int *indices, |