diff options
Diffstat (limited to 'xc/lib/GL/mesa/src/drv/mga/mgaioctl.c')
-rw-r--r-- | xc/lib/GL/mesa/src/drv/mga/mgaioctl.c | 122 |
1 files changed, 52 insertions, 70 deletions
diff --git a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c index f1b7910f1..51f69c81f 100644 --- a/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c +++ b/xc/lib/GL/mesa/src/drv/mga/mgaioctl.c @@ -36,7 +36,7 @@ static void mga_iload_dma_ioctl(mgaContextPtr mmesa, iload.texture.y2 = y2; iload.age = ++mmesa->sarea->last_enqueue; -/* if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) */ + if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "DRM_IOCTL_MGA_ILOAD idx %d dst %x maccess %x %d,%d-%d,%d\n", iload.idx, iload.destOrg, iload.mAccess, iload.texture.x1, @@ -51,7 +51,7 @@ static void mga_iload_dma_ioctl(mgaContextPtr mmesa, } mmesa->iload_buffer = 0; -/* if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) */ + if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "finished iload dma put\n"); } @@ -74,7 +74,6 @@ static drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa ) dma.send_list = NULL; dma.send_sizes = NULL; dma.flags = 0; - dma.flags = DRM_DMA_WAIT /* | DRM_LARGER_OK | DRM_SMALLER_OK */; dma.request_count = 1; dma.request_size = MGA_DMA_BUF_SZ; dma.request_list = &idx; @@ -96,8 +95,7 @@ static drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa ) dma.request_sizes[0], dma.request_list[0], dma.granted_count); - break; -#if 0 + if (retcode == 0 && dma.request_list[0] && dma.request_sizes[0] && @@ -108,7 +106,6 @@ static drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa ) fprintf(stderr, "\n\nflush"); ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH); -#endif } buf = &(mmesa->mgaScreen->bufs->list[idx]); @@ -145,7 +142,7 @@ GLbitfield mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all, clear.clear_color = mmesa->ClearColor; clear.clear_depth = (mgaUI32) (ctx->Depth.Clear * DEPTH_SCALE); - mgaFlushVertices( mmesa ); + FLUSH_BATCH( mmesa ); if (mask & GL_COLOR_BUFFER_BIT) { if (ctx->Color.DriverDrawBuffer == GL_FRONT_LEFT) { @@ -249,10 +246,9 @@ void mgaSwapBuffers( mgaContextPtr mmesa ) static int nrswaps; int retcode; int i; + int tmp; - mgaFlushVertices( mmesa ); - - + FLUSH_BATCH( mmesa ); LOCK_HARDWARE( mmesa ); { @@ -289,29 +285,14 @@ void mgaSwapBuffers( mgaContextPtr mmesa ) } } + tmp = GET_ENQUEUE_AGE(mmesa); -#if 1 - UNLOCK_HARDWARE(mmesa); -#else - { - last_enqueue = mmesa->sarea->lastEnqueue; - last_dispatch = mmesa->sarea->lastDispatch; - UNLOCK_HARDWARE; - - /* Throttle runaway apps - there should be an easier way to sleep - * on dma without locking out the rest of the system! - */ - if (mmesa->lastSwap > last_dispatch) { - drmGetLock(mmesa->driFd, mmesa->hHWContext, DRM_LOCK_QUIESCENT); - DRM_UNLOCK(mmesa->driFd, mmesa->driHwLock, mmesa->hHWContext); - } + UNLOCK_HARDWARE( mmesa ); - mmesa->lastSwap = last_enqueue; - } -#endif + if (GET_DISPATCH_AGE(mmesa) < mmesa->lastSwap) + mgaWaitAge(mmesa, mmesa->lastSwap); - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "finished mgaSwapBuffers\n"); + mmesa->lastSwap = tmp; } @@ -325,8 +306,10 @@ void mgaDDFinish( GLcontext *ctx ) if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "mgaRegetLockQuiescent\n"); - drmUnlock(mmesa->driFd, mmesa->hHWContext); - mgaGetLock( mmesa, DRM_LOCK_QUIESCENT ); + LOCK_HARDWARE( mmesa ); + mgaRegetLockQuiescent( mmesa ); + UNLOCK_HARDWARE( mmesa ); + mmesa->sarea->last_quiescent = mmesa->sarea->last_enqueue; } } @@ -350,7 +333,7 @@ void mgaWaitAgeLocked( mgaContextPtr mmesa, int age ) i++; if (GET_DISPATCH_AGE(mmesa) < age) { -#if 0 +#if 1 if (0) fprintf(stderr, "ioctl\n"); ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH); #else @@ -367,10 +350,11 @@ void mgaWaitAge( mgaContextPtr mmesa, int age ) i++; if (GET_DISPATCH_AGE(mmesa) < age) { -#if 0 +#if 1 LOCK_HARDWARE(mmesa); if (GET_DISPATCH_AGE(mmesa) < age) ioctl(mmesa->driFd, DRM_IOCTL_MGA_FLUSH); + UNLOCK_HARDWARE(mmesa); #else LOCK_HARDWARE_QUIESCENT(mmesa); UNLOCK_HARDWARE(mmesa); @@ -395,16 +379,6 @@ static int intersect_rect( xf86drmClipRectRec *out, -void mgaFlushVertices( mgaContextPtr mmesa ) -{ - if (mmesa->dma_buffer) { - LOCK_HARDWARE( mmesa ); - mgaFlushVerticesLocked( mmesa ); - UNLOCK_HARDWARE( mmesa ); - } - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "finished mgaFlushVertices\n"); -} static void age_mmesa( mgaContextPtr mmesa, int age ) { @@ -416,7 +390,7 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa ) { XF86DRIClipRectPtr pbox = mmesa->pClipRects; int nbox = mmesa->numClipRects; - drmBufPtr real_buffer = mmesa->dma_buffer; + drmBufPtr real_buffer = mmesa->vertex_dma_buffer; drm_mga_vertex_t vertex; static int nrvertex; int retcode; @@ -431,11 +405,11 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa ) if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "mgaFlushVerticesLocked, used %d\n", - mmesa->dma_buffer->used); + mmesa->vertex_dma_buffer->used); vertex.real_idx = real_buffer->idx; vertex.real_used = real_buffer->used; - mmesa->dma_buffer = 0; + mmesa->vertex_dma_buffer = 0; if (nbox >= MGA_NR_SAREA_CLIPRECTS) mmesa->dirty |= MGA_UPLOAD_CLIPRECTS; @@ -448,7 +422,8 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa ) if (nbox == 1) nbox = 0; mmesa->sarea->nbox = nbox; - fprintf(stderr, "Firing vertex -- case a\n"); + if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) + fprintf(stderr, "Firing vertex -- case a nbox %d\n", nbox); retcode = ioctl(mmesa->driFd, DRM_IOCTL_MGA_VERTEX, &vertex); if (retcode) { @@ -456,6 +431,11 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa ) exit(1); } } else { + + if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) + fprintf(stderr, "Firing vertex -- case b, nbox %d dirty %d\n", + nbox, !!(mmesa->dirty & MGA_UPLOAD_CLIPRECTS)); + for (i = 0 ; i < nbox ; ) { int nr = MIN2(i + MGA_NR_SAREA_CLIPRECTS, nbox); @@ -465,7 +445,7 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa ) if (mmesa->scissor) { mmesa->sarea->nbox = 0; - if (MGA_DEBUG&DEBUG_VERBOSE_2D) + if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "SCISSOR %d,%d-%d,%d\n", mmesa->scissor_rect.x1, mmesa->scissor_rect.y1, @@ -477,7 +457,7 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa ) *b = pbox[i]; if (intersect_rect(b, b, &mmesa->scissor_rect)) { - if (MGA_DEBUG&DEBUG_VERBOSE_2D) + if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "BOX %d: %d,%d-%d,%d\n", mmesa->sarea->nbox, b->x1, b->y1, b->x2, b->y2); @@ -506,9 +486,9 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa ) vertex.idx = tmp->idx; } else { vertex.idx = vertex.real_idx; - vertex.discard = discard; } + vertex.discard = discard; vertex.age = ++mmesa->sarea->last_enqueue; age_mmesa(mmesa, vertex.age); @@ -533,6 +513,12 @@ void mgaFlushVerticesLocked( mgaContextPtr mmesa ) fprintf(stderr, "finished mgaFlushVerticesLocked\n"); } +void mgaFlushVertices( mgaContextPtr mmesa ) +{ + LOCK_HARDWARE( mmesa ); + mgaFlushVerticesLocked( mmesa ); + UNLOCK_HARDWARE( mmesa ); +} mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ) @@ -540,17 +526,22 @@ mgaUI32 *mgaAllocVertexDwords( mgaContextPtr mmesa, int dwords ) int bytes = dwords * 4; mgaUI32 *head; - if (!mmesa->dma_buffer) - mgaGetVertexDmaBuffer( mmesa ); - else if (mmesa->dma_buffer->used + bytes > mmesa->dma_buffer->total) { - mgaFlushVertices( mmesa ); - mgaGetVertexDmaBuffer( mmesa ); + if (!mmesa->vertex_dma_buffer) { + LOCK_HARDWARE( mmesa ); + mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa ); + UNLOCK_HARDWARE( mmesa ); + } else if (mmesa->vertex_dma_buffer->used + bytes > + mmesa->vertex_dma_buffer->total) { + LOCK_HARDWARE( mmesa ); + mgaFlushVerticesLocked( mmesa ); + mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa ); + UNLOCK_HARDWARE( mmesa ); } - head = (mgaUI32 *)((char *)mmesa->dma_buffer->address + - mmesa->dma_buffer->used); + head = (mgaUI32 *)((char *)mmesa->vertex_dma_buffer->address + + mmesa->vertex_dma_buffer->used); - mmesa->dma_buffer->used += bytes; + mmesa->vertex_dma_buffer->used += bytes; return head; } @@ -574,7 +565,7 @@ void mgaFireILoadLocked( mgaContextPtr mmesa, mga_iload_dma_ioctl( mmesa, x, y, x+width, y+height, offset, maccess ); } -void mgaGetILoadBuffer( mgaContextPtr mmesa ) +void mgaGetILoadBufferLocked( mgaContextPtr mmesa ) { if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) fprintf(stderr, "start mgaGetIloadBuffer (buffer now %p)\n", @@ -584,19 +575,10 @@ void mgaGetILoadBuffer( mgaContextPtr mmesa ) fprintf(stderr, "finished mgaGetIloadBuffer\n"); } -void mgaGetVertexDmaBuffer( mgaContextPtr mmesa ) -{ - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "start mgaGetVertexDmaBuffer (buffer now %p)\n", - mmesa->dma_buffer); - mmesa->dma_buffer = mga_get_buffer_ioctl( mmesa ); - if (MGA_DEBUG&DEBUG_VERBOSE_IOCTL) - fprintf(stderr, "finished mgaGetVertexDmaBuffer\n"); -} static void mgaDDFlush( GLcontext *ctx ) { - mgaFlushVertices( MGA_CONTEXT( ctx ) ); + FLUSH_BATCH( MGA_CONTEXT( ctx ) ); } |