From 6e56f905d00f27257f252be3c2666dad52aeab45 Mon Sep 17 00:00:00 2001 From: Ian Romanick Date: Wed, 18 May 2005 00:37:32 +0000 Subject: More comments. More dead-code removed. More clean-up. --- src/mesa/drivers/dri/mga/mga_xmesa.c | 10 +-- src/mesa/drivers/dri/mga/mga_xmesa.h | 1 - src/mesa/drivers/dri/mga/mgaioctl.c | 131 ++++++++++++++++------------------- src/mesa/drivers/dri/mga/mgaioctl.h | 11 --- 4 files changed, 66 insertions(+), 87 deletions(-) (limited to 'src/mesa') diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.c b/src/mesa/drivers/dri/mga/mga_xmesa.c index a4bb95a791..6c77db5a32 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.c +++ b/src/mesa/drivers/dri/mga/mga_xmesa.c @@ -21,9 +21,13 @@ * 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. + */ + +/** + * \file mga_xmesa.c + * MGA screen and context initialization / creation code. * - * Authors: - * Keith Whitwell + * \author Keith Whitwell */ #include @@ -909,8 +913,6 @@ void mgaGetLock( mgaContextPtr mmesa, GLuint flags ) for ( i = 0 ; i < mmesa->nr_heaps ; i++ ) { DRI_AGE_TEXTURES( mmesa->texture_heaps[ i ] ); } - - sarea->last_quiescent = -1; /* just kill it for now */ } diff --git a/src/mesa/drivers/dri/mga/mga_xmesa.h b/src/mesa/drivers/dri/mga/mga_xmesa.h index 2bc0eaa9d5..14110b8f1e 100644 --- a/src/mesa/drivers/dri/mga/mga_xmesa.h +++ b/src/mesa/drivers/dri/mga/mga_xmesa.h @@ -97,7 +97,6 @@ extern void mgaEmitHwStateLocked( mgaContextPtr mmesa ); extern void mgaEmitScissorValues( mgaContextPtr mmesa, int box_nr, int emit ); #define GET_DISPATCH_AGE( mmesa ) mmesa->sarea->last_dispatch -#define GET_ENQUEUE_AGE( mmesa ) mmesa->sarea->last_enqueue diff --git a/src/mesa/drivers/dri/mga/mgaioctl.c b/src/mesa/drivers/dri/mga/mgaioctl.c index 9ebb48f43c..d741b57cea 100644 --- a/src/mesa/drivers/dri/mga/mgaioctl.c +++ b/src/mesa/drivers/dri/mga/mgaioctl.c @@ -20,12 +20,15 @@ * 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. + */ + +/** + * \file mgaioctl.c + * MGA IOCTL related wrapper functions. * - * Authors: - * Keith Whitwell - * Gareth Hughes + * \author Keith Whitwell + * \author Gareth Hughes */ -/* $XFree86: xc/lib/GL/mesa/src/drv/mga/mgaioctl.c,v 1.16 2002/12/16 16:18:52 dawes Exp $ */ #include #include "mtypes.h" @@ -415,26 +418,52 @@ void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv ) } -/* This is overkill +/** + * Implement the hardware-specific portion of \c glFinish. + * + * Flushes all pending commands to the hardware and wait for them to finish. + * + * \param ctx Context where the \c glFinish command was issued. + * + * \todo + * This is overkill. The lock, update-lock, unlock sequence grabs the + * hardware, waits for \b all hardware activity to finish, then releases the + * hardware. A better way would be to flush the pending DMA buffers, emit + * a SOFTRAP, and wait for the SOFTRAP. + * + * \sa glFinish, mgaFlush, mgaFlushDMA */ static void mgaFinish( GLcontext *ctx ) { - mgaContextPtr mmesa = MGA_CONTEXT(ctx); + mgaContextPtr mmesa = MGA_CONTEXT(ctx); - FLUSH_BATCH( mmesa ); - if (1/*mmesa->sarea->last_quiescent != mmesa->sarea->last_enqueue*/) { - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "mgaRegetLockQuiescent\n"); + LOCK_HARDWARE( mmesa ); + if ( mmesa->vertex_dma_buffer != NULL ) { + mgaFlushVerticesLocked( mmesa ); + } - LOCK_HARDWARE( mmesa ); - UPDATE_LOCK( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH ); - UNLOCK_HARDWARE( mmesa ); + if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) { + fprintf(stderr, "mgaRegetLockQuiescent\n"); + } - mmesa->sarea->last_quiescent = mmesa->sarea->last_enqueue; - } + UPDATE_LOCK( mmesa, DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH ); + UNLOCK_HARDWARE( mmesa ); } + +/** + * Flush all commands upto at least a certain point to the hardware. + * + * \note + * The term "wait" in the name of this function is misleading. It doesn't + * actually wait for anything. It just makes sure that the commands have + * been flushed to the hardware. + * + * \warning + * As the name implies, this function assumes that the hardware lock is + * held on entry. + */ void mgaWaitAgeLocked( mgaContextPtr mmesa, int age ) { if (GET_DISPATCH_AGE(mmesa) < age) { @@ -443,18 +472,6 @@ void mgaWaitAgeLocked( mgaContextPtr mmesa, int age ) } -void mgaWaitAge( mgaContextPtr mmesa, int age ) -{ - if (GET_DISPATCH_AGE(mmesa) < age) { - LOCK_HARDWARE(mmesa); - if (GET_DISPATCH_AGE(mmesa) < age) { - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH ); - } - UNLOCK_HARDWARE(mmesa); - } -} - - static GLboolean intersect_rect( drm_clip_rect_t *out, const drm_clip_rect_t *a, const drm_clip_rect_t *b ) @@ -477,9 +494,6 @@ static void age_mmesa( mgaContextPtr mmesa, int age ) if (mmesa->CurrentTexObj[1]) mmesa->CurrentTexObj[1]->age = age; } -#ifdef __i386__ -static int __break_vertex = 0; -#endif void mgaFlushVerticesLocked( mgaContextPtr mmesa ) { @@ -578,13 +592,6 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa ) } } - /* Do we really need to do this ? */ -#ifdef __i386__ - if ( __break_vertex ) { - __asm__ __volatile__ ( "int $3" ); - } -#endif - mmesa->dirty &= ~MGA_UPLOAD_CLIPRECTS; } @@ -620,46 +627,29 @@ void mgaGetILoadBufferLocked( mgaContextPtr mmesa ) mmesa->iload_buffer = mga_get_buffer_ioctl( mmesa ); } -drmBufPtr mgaGetBufferLocked( mgaContextPtr mmesa ) -{ - return mga_get_buffer_ioctl( mmesa ); -} - - +/** + * Implement the hardware-specific portion of \c glFlush. + * + * \param ctx Context to be flushed. + * + * \sa glFlush, mgaFinish, mgaFlushDMA + */ static void mgaFlush( GLcontext *ctx ) { - mgaContextPtr mmesa = MGA_CONTEXT( ctx ); + mgaContextPtr mmesa = MGA_CONTEXT( ctx ); - FLUSH_BATCH( mmesa ); + LOCK_HARDWARE( mmesa ); + if ( mmesa->vertex_dma_buffer != NULL ) { + mgaFlushVerticesLocked( mmesa ); + } - /* This may be called redundantly - dispatch_age may trail what - * has actually been sent and processed by the hardware. - */ - if (1 || GET_DISPATCH_AGE( mmesa ) < mmesa->sarea->last_enqueue) { - LOCK_HARDWARE( mmesa ); - UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH ); - UNLOCK_HARDWARE( mmesa ); - } + UPDATE_LOCK( mmesa, DRM_LOCK_FLUSH ); + UNLOCK_HARDWARE( mmesa ); } - - -void mgaReleaseBufLocked( mgaContextPtr mmesa, drmBufPtr buffer ) -{ - drm_mga_vertex_t vertex; - - if (!buffer) return; - - vertex.idx = buffer->idx; - vertex.used = 0; - vertex.discard = 1; - drmCommandWrite( mmesa->driFd, DRM_MGA_VERTEX, - &vertex, sizeof(vertex) ); -} - int mgaFlushDMA( int fd, drmLockFlags flags ) { drm_lock_t lock; @@ -667,9 +657,8 @@ int mgaFlushDMA( int fd, drmLockFlags flags ) memset( &lock, 0, sizeof(lock) ); - if ( flags & DRM_LOCK_QUIESCENT ) lock.flags |= DRM_LOCK_QUIESCENT; - if ( flags & DRM_LOCK_FLUSH ) lock.flags |= DRM_LOCK_FLUSH; - if ( flags & DRM_LOCK_FLUSH_ALL ) lock.flags |= DRM_LOCK_FLUSH_ALL; + lock.flags = flags & (DRM_LOCK_QUIESCENT | DRM_LOCK_FLUSH + | DRM_LOCK_FLUSH_ALL); do { ret = drmCommandWrite( fd, DRM_MGA_FLUSH, &lock, sizeof(lock) ); diff --git a/src/mesa/drivers/dri/mga/mgaioctl.h b/src/mesa/drivers/dri/mga/mgaioctl.h index c83394af59..f3ae749ca9 100644 --- a/src/mesa/drivers/dri/mga/mgaioctl.h +++ b/src/mesa/drivers/dri/mga/mgaioctl.h @@ -36,27 +36,16 @@ void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv ); void mgaWaitForVBlank( mgaContextPtr mmesa ); -GLuint *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ); - - void mgaGetILoadBufferLocked( mgaContextPtr mmesa ); -drmBufPtr mgaGetBufferLocked( mgaContextPtr mmesa ); - - void mgaFireILoadLocked( mgaContextPtr mmesa, GLuint offset, GLuint length ); void mgaWaitAgeLocked( mgaContextPtr mmesa, int age ); -void mgaWaitAge( mgaContextPtr mmesa, int age ); void mgaFlushVertices( mgaContextPtr mmesa ); void mgaFlushVerticesLocked( mgaContextPtr mmesa ); -void mgaReleaseBufLocked( mgaContextPtr mmesa, drmBufPtr buffer ); int mgaFlushDMA( int fd, drmLockFlags flags ); -void mgaDDFlush( GLcontext *ctx ); -void mgaDDFinish( GLcontext *ctx ); - void mgaInitIoctlFuncs( struct dd_function_table *functions ); #define FLUSH_BATCH(mmesa) do { \ -- cgit v1.2.3