Rearranged some code and added some comments to mgaAllocDmaLow. The
authorIan Romanick <idr@us.ibm.com>
Mon, 16 May 2005 23:23:51 +0000 (23:23 +0000)
committerIan Romanick <idr@us.ibm.com>
Mon, 16 May 2005 23:23:51 +0000 (23:23 +0000)
modified code performs identically, but cuts 16KiB from the resulting
mga_dri.so.

src/mesa/drivers/dri/mga/mgaioctl.h

index 19785ea..c83394a 100644 (file)
@@ -78,14 +78,22 @@ GLuint *mgaAllocDmaLow( mgaContextPtr mmesa, int bytes )
 {
    GLuint *head;
 
-   if (!mmesa->vertex_dma_buffer) {
+   /* If there is no DMA buffer currently allocated or the currently
+    * allocated DMA buffer doesn't have enough room left for this request,
+    * a new buffer will need to be allocated.
+    */
+   if ( (mmesa->vertex_dma_buffer == NULL)
+       || ((mmesa->vertex_dma_buffer->used + bytes) 
+           > mmesa->vertex_dma_buffer->total) ) {
       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 );
+
+      /* In the case where the existing buffer does not have enough room,
+       * we need to flush it out to the hardware.
+       */
+      if ( mmesa->vertex_dma_buffer != NULL ) {
+        mgaFlushVerticesLocked( mmesa );
+      }
+          
       mmesa->vertex_dma_buffer = mga_get_buffer_ioctl( mmesa );
       UNLOCK_HARDWARE( mmesa );
    }