fix GL_LINE_LOOP with drivers using own render pipeline stage (#12410, #13527)
[mesa.git] / src / mesa / drivers / dri / mga / mgaioctl.c
index df253d15934fef8870188bae5c993dafa18d0535..ff26b9475b9e9271aa1445c190062a2505e0331c 100644 (file)
 #include "vblank.h"
 
 
-int
+static int
 mgaSetFence( mgaContextPtr mmesa, uint32_t * fence )
 {
     int ret = ENOSYS;
 
-    if ( mmesa->driScreen->drmMinor >= 2 ) {
+    if ( mmesa->driScreen->drm_version.minor >= 2 ) {
        ret = drmCommandWriteRead( mmesa->driScreen->fd, DRM_MGA_SET_FENCE,
                                   fence, sizeof( uint32_t ));
        if (ret) {
@@ -68,12 +68,12 @@ mgaSetFence( mgaContextPtr mmesa, uint32_t * fence )
 }
 
 
-int
+static int
 mgaWaitFence( mgaContextPtr mmesa, uint32_t fence, uint32_t * curr_fence )
 {
     int ret = ENOSYS;
 
-    if ( mmesa->driScreen->drmMinor >= 2 ) {
+    if ( mmesa->driScreen->drm_version.minor >= 2 ) {
        uint32_t temp = fence;
        
        ret = drmCommandWriteRead( mmesa->driScreen->fd,
@@ -204,8 +204,7 @@ drmBufPtr mga_get_buffer_ioctl( mgaContextPtr mmesa )
 
 
 static void
-mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
-            GLint cx, GLint cy, GLint cw, GLint ch )
+mgaClear( GLcontext *ctx, GLbitfield mask )
 {
    mgaContextPtr mmesa = MGA_CONTEXT(ctx);
    __DRIdrawablePrivate *dPriv = mmesa->driDrawable;
@@ -218,6 +217,7 @@ mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
    int i;
    static int nrclears;
    drm_mga_clear_t clear;
+   GLint cx, cy, cw, ch;
 
    FLUSH_BATCH( mmesa );
 
@@ -250,6 +250,12 @@ mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
    if ( flags ) {
       LOCK_HARDWARE( mmesa );
 
+      /* compute region after locking: */
+      cx = ctx->DrawBuffer->_Xmin;
+      cy = ctx->DrawBuffer->_Ymin;
+      cw = ctx->DrawBuffer->_Xmax - cx;
+      ch = ctx->DrawBuffer->_Ymax - cy;
+
       if ( mmesa->dirty_cliprects )
         mgaUpdateRects( mmesa, (MGA_FRONT | MGA_BACK) );
 
@@ -269,7 +275,8 @@ mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
         drm_clip_rect_t *b = mmesa->sarea->boxes;
         int n = 0;
 
-        if (!all) {
+        if (cw != dPriv->w || ch != dPriv->h) {
+            /* clear subregion */
            for ( ; i < nr ; i++) {
               GLint x = box[i].x1;
               GLint y = box[i].y1;
@@ -291,6 +298,7 @@ mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
               n++;
            }
         } else {
+            /* clear whole window */
            for ( ; i < nr ; i++) {
               *b++ = box[i];
               n++;
@@ -325,7 +333,7 @@ mgaClear( GLcontext *ctx, GLbitfield mask, GLboolean all,
    }
 
    if (mask) 
-      _swrast_Clear( ctx, mask, all, cx, cy, cw, ch );
+      _swrast_Clear( ctx, mask );
 }
 
 
@@ -401,7 +409,7 @@ static void mgaWaitForFrameCompletion( mgaContextPtr mmesa )
 /*
  * Copy the back buffer to the front buffer.
  */
-void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
+void mgaCopyBuffer( __DRIdrawablePrivate *dPriv )
 {
    mgaContextPtr mmesa;
    drm_clip_rect_t *pbox;
@@ -420,8 +428,7 @@ void mgaCopyBuffer( const __DRIdrawablePrivate *dPriv )
    FLUSH_BATCH( mmesa );
 
    mgaWaitForFrameCompletion( mmesa );
-   driWaitForVBlank( dPriv, & mmesa->vbl_seq, mmesa->vblank_flags,
-                    & missed_target );
+   driWaitForVBlank( dPriv, & missed_target );
    if ( missed_target ) {
       mmesa->swap_missed_count++;
       (void) (*dri_interface->getUST)( & mmesa->swap_missed_ust );