diff -aup -x '.*' -x CVS -x '*.o' -x '*.so' mach64/mach64_context.c mach64-vtx/mach64_context.c --- mach64/mach64_context.c 2005-10-19 05:46:42.000000000 +0300 +++ mach64-vtx/mach64_context.c 2006-03-11 20:06:43.000000000 +0200 @@ -192,14 +192,6 @@ GLboolean mach64CreateContext( const __G mmesa->boxes = ( getenv( "LIBGL_PERFORMANCE_BOXES" ) != NULL ); #endif - /* Allocate the vertex buffer - */ - mmesa->vert_buf = ALIGN_MALLOC(MACH64_BUFFER_SIZE, 32); - if ( !mmesa->vert_buf ) - return GL_FALSE; - mmesa->vert_used = 0; - mmesa->vert_total = MACH64_BUFFER_SIZE; - /* Initialize the software rasterizer and helper modules. */ _swrast_CreateContext( ctx ); @@ -277,10 +269,6 @@ void mach64DestroyContext( __DRIcontextP mach64FreeVB( mmesa->glCtx ); - /* Free the vertex buffer */ - if ( mmesa->vert_buf ) - ALIGN_FREE( mmesa->vert_buf ); - /* free the Mesa context */ mmesa->glCtx->DriverCtx = NULL; _mesa_destroy_context(mmesa->glCtx); diff -aup -x '.*' -x CVS -x '*.o' -x '*.so' mach64/mach64_context.h mach64-vtx/mach64_context.h --- mach64/mach64_context.h 2005-11-28 15:17:16.000000000 +0200 +++ mach64-vtx/mach64_context.h 2006-03-12 00:02:32.000000000 +0200 @@ -210,8 +210,8 @@ struct mach64_context { GLuint RenderIndex; GLfloat hw_viewport[16]; GLfloat depth_scale; + GLuint vertex_size; - GLuint vertex_stride_shift; GLuint vertex_format; GLuint num_verts; GLubyte *verts; @@ -252,9 +252,7 @@ struct mach64_context { /* DMA buffers */ - void *vert_buf; - size_t vert_total; - unsigned vert_used; + drmBufPtr vert_buf; GLuint hw_primitive; GLenum render_primitive; @@ -376,7 +374,7 @@ do { \ #define DMAADVANCE() \ do { \ if (outcount < requested) { \ - mmesa->vert_used -= (requested - outcount) * 4; \ + mmesa->vert_buf->used -= (requested - outcount) * 4; \ } \ } while(0) diff -aup -x '.*' -x CVS -x '*.o' -x '*.so' mach64/mach64_ioctl.c mach64-vtx/mach64_ioctl.c --- mach64/mach64_ioctl.c 2006-03-13 01:20:17.000000000 +0200 +++ mach64-vtx/mach64_ioctl.c 2006-03-13 01:21:06.000000000 +0200 @@ -100,17 +100,17 @@ void mach64FlushVerticesLocked( mach64Co { drm_clip_rect_t *pbox = mmesa->pClipRects; int nbox = mmesa->numClipRects; - void *buffer = mmesa->vert_buf; - int count = mmesa->vert_used; + drmBufPtr buffer = mmesa->vert_buf; + int count = buffer->used; int prim = mmesa->hw_primitive; int fd = mmesa->driScreen->fd; drm_mach64_vertex_t vertex; int i, ret; mmesa->num_verts = 0; - mmesa->vert_used = 0; + mmesa->vert_buf = NULL; - if ( !count ) + if ( !buffer ) return; if ( mmesa->dirty & ~MACH64_UPLOAD_CLIPRECTS ) @@ -130,7 +130,7 @@ void mach64FlushVerticesLocked( mach64Co mmesa->sarea->nbox = nbox; vertex.prim = prim; - vertex.buf = buffer; + vertex.idx = buffer->idx; vertex.used = count; vertex.discard = 1; ret = drmCommandWrite( fd, DRM_MACH64_VERTEX, &vertex, sizeof(drm_mach64_vertex_t) ); @@ -161,7 +161,7 @@ void mach64FlushVerticesLocked( mach64Co mmesa->sarea->dirty |= MACH64_UPLOAD_CLIPRECTS; vertex.prim = prim; - vertex.buf = buffer; + vertex.idx = buffer->idx; vertex.used = count; vertex.discard = discard; ret = drmCommandWrite( fd, DRM_MACH64_VERTEX, &vertex, sizeof(drm_mach64_vertex_t) ); diff -aup -x '.*' -x CVS -x '*.o' -x '*.so' mach64/mach64_ioctl.h mach64-vtx/mach64_ioctl.h --- mach64/mach64_ioctl.h 2005-02-01 01:40:05.000000000 +0200 +++ mach64-vtx/mach64_ioctl.h 2006-03-13 01:00:57.000000000 +0200 @@ -48,28 +48,37 @@ static __inline void *mach64AllocDmaLow( { CARD32 *head; - if ( mmesa->vert_used + bytes > mmesa->vert_total ) { + if ( !mmesa->vert_buf ) { + LOCK_HARDWARE( mmesa ); + mmesa->vert_buf = mach64GetBufferLocked( mmesa ); + UNLOCK_HARDWARE( mmesa ); + } else if ( mmesa->vert_buf->used + bytes > mmesa->vert_buf->total ) { LOCK_HARDWARE( mmesa ); mach64FlushVerticesLocked( mmesa ); + mmesa->vert_buf = mach64GetBufferLocked( mmesa ); UNLOCK_HARDWARE( mmesa ); } - head = (CARD32 *)((char *)mmesa->vert_buf + mmesa->vert_used); - mmesa->vert_used += bytes; + head = (CARD32 *)((char *)mmesa->vert_buf->address + mmesa->vert_buf->used); + mmesa->vert_buf->used += bytes; return head; } +/* Allocate indirect buffer for client-side state emits - currently unused */ static __inline void *mach64AllocDmaLocked( mach64ContextPtr mmesa, int bytes ) { CARD32 *head; - if ( mmesa->vert_used + bytes > mmesa->vert_total ) { + if ( !mmesa->vert_buf ) { + mmesa->vert_buf = mach64GetBufferLocked( mmesa ); + } else if ( mmesa->vert_buf->used + bytes > mmesa->vert_buf->total ) { mach64FlushVerticesLocked( mmesa ); + mmesa->vert_buf = mach64GetBufferLocked( mmesa ); } - head = (CARD32 *)((char *)mmesa->vert_buf + mmesa->vert_used); - mmesa->vert_used += bytes; + head = (CARD32 *)((char *)mmesa->vert_buf->address + mmesa->vert_buf->used); + mmesa->vert_buf->used += bytes; return head; } @@ -95,7 +104,7 @@ extern void mach64InitIoctlFuncs( struct do { \ if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \ fprintf( stderr, "FLUSH_BATCH in %s\n", __FUNCTION__ ); \ - if ( mmesa->vert_used ) { \ + if ( mmesa->vert_buf ) { \ mach64FlushVertices( mmesa ); \ } \ } while (0) @@ -112,7 +121,7 @@ do { \ CARD32 _tmp; \ if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \ fprintf( stderr, "FINISH_DMA_LOCKED in %s\n", __FUNCTION__ ); \ - if ( mmesa->vert_used ) { \ + if ( mmesa->vert_buf ) { \ mach64FlushVerticesLocked( mmesa ); \ } \ mach64WaitForIdleLocked( mmesa ); \ @@ -124,7 +133,7 @@ do { \ do { \ if ( MACH64_DEBUG & DEBUG_VERBOSE_IOCTL ) \ fprintf( stderr, "FLUSH_DMA_LOCKED in %s\n", __FUNCTION__ ); \ - if ( mmesa->vert_used ) { \ + if ( mmesa->vert_buf ) { \ mach64FlushVerticesLocked( mmesa ); \ } \ mach64FlushDMALocked( mmesa ); \ Common subdirectories: mach64/server and mach64-vtx/server