View | Details | Raw Unified | Return to bug 157051
Collapse All | Expand All

(-)include/GL/internal/dri_interface.h (+8 lines)
Lines 472-477 Link Here
472
     * \since Internal API version 20030317.
472
     * \since Internal API version 20030317.
473
     */
473
     */
474
    unsigned swap_interval;
474
    unsigned swap_interval;
475
476
    /**
477
     * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
478
     *
479
     * \since Internal API version 20060314.
480
     */
481
    void (*copySubBuffer)(__DRInativeDisplay *dpy, void *drawablePrivate,
482
			  int x, int y, int w, int h);
475
};
483
};
476
484
477
#endif
485
#endif
(-)src/glx/x11/glxcmds.c (-9 / +61 lines)
Lines 2570-2587 Link Here
2570
   return 0;
2570
   return 0;
2571
}
2571
}
2572
2572
2573
2573
#define X_GLXvop_CopySubBufferMESA 5154 /* temporary */
2574
PUBLIC void glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
2574
PUBLIC void glXCopySubBufferMESA(Display *dpy, GLXDrawable drawable,
2575
				 int x, int y, int width, int height)
2575
				 int x, int y, int width, int height)
2576
{
2576
{
2577
   (void) dpy;
2577
    xGLXVendorPrivateReq *req;
2578
   (void) drawable;
2578
    GLXContext gc;
2579
   (void) x;
2579
    GLXContextTag tag;
2580
   (void) y;
2580
    CARD32 *drawable_ptr;
2581
   (void) width;
2581
    INT32 *x_ptr, *y_ptr, *w_ptr, *h_ptr;
2582
   (void) height;
2582
    CARD8 opcode;
2583
}
2583
2584
#ifdef GLX_DIRECT_RENDERING
2585
    int screen;
2586
    __DRIdrawable *pdraw = GetDRIDrawable( dpy, drawable, & screen );
2587
    if ( pdraw != NULL ) {
2588
	__GLXscreenConfigs * const psc = GetGLXScreenConfigs( dpy, screen );
2589
	if ( __glXExtensionBitIsEnabled( psc, MESA_copy_sub_buffer_bit ) ) {
2590
	    (*pdraw->copySubBuffer)(dpy, pdraw->private, x, y, width, height);
2591
	}
2592
2593
	return;
2594
    }
2595
#endif
2596
2597
    opcode = __glXSetupForCommand(dpy);
2598
    if (!opcode)
2599
	return;
2600
2601
    /*
2602
    ** The calling thread may or may not have a current context.  If it
2603
    ** does, send the context tag so the server can do a flush.
2604
    */
2605
    gc = __glXGetCurrentContext();
2606
    if ((gc != NULL) && (dpy == gc->currentDpy) &&
2607
	((drawable == gc->currentDrawable) ||
2608
	 (drawable == gc->currentReadable)) ) {
2609
	tag = gc->currentContextTag;
2610
    } else {
2611
	tag = 0;
2612
    }
2613
2614
    LockDisplay(dpy);
2615
    GetReqExtra(GLXVendorPrivate, sizeof(CARD32) + sizeof(INT32) * 4,req);
2616
    req->reqType = opcode;
2617
    req->glxCode = X_GLXVendorPrivate;
2618
    req->vendorCode = X_GLXvop_CopySubBufferMESA;
2619
    req->contextTag = tag;
2584
2620
2621
    drawable_ptr = (CARD32 *) (req + 1);
2622
    x_ptr = (INT32 *) (drawable_ptr + 1);
2623
    y_ptr = (INT32 *) (drawable_ptr + 2);
2624
    w_ptr = (INT32 *) (drawable_ptr + 3);
2625
    h_ptr = (INT32 *) (drawable_ptr + 4);
2626
2627
    *drawable_ptr = drawable;
2628
    *x_ptr = x;
2629
    *y_ptr = y;
2630
    *w_ptr = width;
2631
    *h_ptr = height;
2632
2633
    UnlockDisplay(dpy);
2634
    SyncHandle();
2635
}
2585
2636
2586
PUBLIC Bool glXSet3DfxModeMESA( int mode )
2637
PUBLIC Bool glXSet3DfxModeMESA( int mode )
2587
{
2638
{
Lines 2973-2980 Link Here
2973
     *            months ago. :(
3024
     *            months ago. :(
2974
     * 20050727 - Gut all the old interfaces.  This breaks compatability with
3025
     * 20050727 - Gut all the old interfaces.  This breaks compatability with
2975
     *            any DRI driver built to any previous version.
3026
     *            any DRI driver built to any previous version.
3027
     * 20060314 - Added support for GLX_MESA_copy_sub_buffer.
2976
     */
3028
     */
2977
    return 20050727;
3029
    return 20060314;
2978
}
3030
}
2979
3031
2980
3032
(-)src/glx/x11/glxextensions.c (-1 / +1 lines)
Lines 79-85 Link Here
79
   { GLX(EXT_visual_rating),           VER(0,0), Y, Y, N, N },
79
   { GLX(EXT_visual_rating),           VER(0,0), Y, Y, N, N },
80
   { GLX(MESA_agp_offset),             VER(0,0), N, N, N, Y }, /* Deprecated */
80
   { GLX(MESA_agp_offset),             VER(0,0), N, N, N, Y }, /* Deprecated */
81
   { GLX(MESA_allocate_memory),        VER(0,0), Y, N, N, Y },
81
   { GLX(MESA_allocate_memory),        VER(0,0), Y, N, N, Y },
82
   { GLX(MESA_copy_sub_buffer),        VER(0,0), N, N, N, N }, /* Deprecated? */
82
   { GLX(MESA_copy_sub_buffer),        VER(0,0), Y, N, N, N },
83
   { GLX(MESA_pixmap_colormap),        VER(0,0), N, N, N, N }, /* Deprecated */
83
   { GLX(MESA_pixmap_colormap),        VER(0,0), N, N, N, N }, /* Deprecated */
84
   { GLX(MESA_release_buffers),        VER(0,0), N, N, N, N }, /* Deprecated */
84
   { GLX(MESA_release_buffers),        VER(0,0), N, N, N, N }, /* Deprecated */
85
   { GLX(MESA_set_3dfx_mode),          VER(0,0), N, N, N, N }, /* Deprecated */
85
   { GLX(MESA_set_3dfx_mode),          VER(0,0), N, N, N, N }, /* Deprecated */
(-)src/mesa/drivers/dri/common/dri_util.c (+10 lines)
Lines 547-552 Link Here
547
                                                           remainder );
547
                                                           remainder );
548
}
548
}
549
549
550
static void driCopySubBuffer( __DRInativeDisplay *dpy, void *drawablePrivate,
551
			      int x, int y, int w, int h)
552
{
553
    __DRIdrawablePrivate *dPriv = (__DRIdrawablePrivate *) drawablePrivate;
554
    dPriv->driScreenPriv->DriverAPI.CopySubBuffer(dPriv, x, y, w, h);
555
    (void) dpy;
556
}
550
557
551
/**
558
/**
552
 * This is called via __DRIscreenRec's createNewDrawable pointer.
559
 * This is called via __DRIscreenRec's createNewDrawable pointer.
Lines 623-628 Link Here
623
    pdraw->frameTracking = NULL;
630
    pdraw->frameTracking = NULL;
624
    pdraw->queryFrameTracking = driQueryFrameTracking;
631
    pdraw->queryFrameTracking = driQueryFrameTracking;
625
632
633
    if (driCompareGLXAPIVersion (20060314) >= 0)
634
	pdraw->copySubBuffer = driCopySubBuffer;
635
626
    /* This special default value is replaced with the configured
636
    /* This special default value is replaced with the configured
627
     * default value when the drawable is first bound to a direct
637
     * default value when the drawable is first bound to a direct
628
     * rendering context. 
638
     * rendering context. 
(-)src/mesa/drivers/dri/common/dri_util.h (+2 lines)
Lines 189-194 Link Here
189
    int64_t (*SwapBuffersMSC)( __DRIdrawablePrivate *priv, int64_t target_msc,
189
    int64_t (*SwapBuffersMSC)( __DRIdrawablePrivate *priv, int64_t target_msc,
190
			       int64_t divisor, int64_t remainder );
190
			       int64_t divisor, int64_t remainder );
191
    /*@}*/
191
    /*@}*/
192
    void (*CopySubBuffer)(__DRIdrawablePrivate *driDrawPriv,
193
			  int x, int y, int w, int h);
192
};
194
};
193
195
194
196
(-)src/mesa/drivers/dri/i915/intel_batchbuffer.c (-14 / +39 lines)
Lines 366-372 Link Here
366
/*
366
/*
367
 * Copy the back buffer to the front buffer. 
367
 * Copy the back buffer to the front buffer. 
368
 */
368
 */
369
void intelCopyBuffer( const __DRIdrawablePrivate *dPriv ) 
369
void intelCopyBuffer( const __DRIdrawablePrivate *dPriv,
370
		      const drm_clip_rect_t	 *rect)
370
{
371
{
371
   intelContextPtr intel;
372
   intelContextPtr intel;
372
   GLboolean   missed_target;
373
   GLboolean   missed_target;
Lines 385-399 Link Here
385
   
386
   
386
   LOCK_HARDWARE( intel );
387
   LOCK_HARDWARE( intel );
387
   intelWaitForFrameCompletion( intel );
388
   intelWaitForFrameCompletion( intel );
388
   UNLOCK_HARDWARE( intel );
389
   driWaitForVBlank( dPriv, &intel->vbl_seq, intel->vblank_flags, & missed_target );
390
389
391
   LOCK_HARDWARE( intel );
390
   if (!rect)
391
   {
392
       UNLOCK_HARDWARE( intel );
393
       driWaitForVBlank( dPriv, &intel->vbl_seq, intel->vblank_flags, & missed_target );
394
       LOCK_HARDWARE( intel );
395
   }
392
   {
396
   {
393
      const intelScreenPrivate *intelScreen = intel->intelScreen;
397
      const intelScreenPrivate *intelScreen = intel->intelScreen;
394
      const __DRIdrawablePrivate *dPriv = intel->driDrawable;
398
      const __DRIdrawablePrivate *dPriv = intel->driDrawable;
395
      const int nbox = dPriv->numClipRects;
399
      const int nbox = dPriv->numClipRects;
396
      const drm_clip_rect_t *pbox = dPriv->pClipRects;
400
      const drm_clip_rect_t *pbox = dPriv->pClipRects;
401
      drm_clip_rect_t box;
397
      const int cpp = intelScreen->cpp;
402
      const int cpp = intelScreen->cpp;
398
      const int pitch = intelScreen->front.pitch; /* in bytes */
403
      const int pitch = intelScreen->front.pitch; /* in bytes */
399
      int i;
404
      int i;
Lines 429-446 Link Here
429
	    continue;
434
	    continue;
430
         }
435
         }
431
436
437
	 box = *pbox;
438
439
	 if (rect)
440
	 {
441
	     if (rect->x1 > box.x1)
442
		 box.x1 = rect->x1;
443
	     if (rect->y1 > box.y1)
444
		 box.y1 = rect->y1;
445
	     if (rect->x2 < box.x2)
446
		 box.x2 = rect->x2;
447
	     if (rect->y2 < box.y2)
448
		 box.y2 = rect->y2;
449
450
	     if (box.x1 > box.x2 || box.y1 > box.y2)
451
		 continue;
452
	 }
453
432
	 BEGIN_BATCH( 8);
454
	 BEGIN_BATCH( 8);
433
	 OUT_BATCH( CMD );
455
	 OUT_BATCH( CMD );
434
	 OUT_BATCH( BR13 );
456
	 OUT_BATCH( BR13 );
435
	 OUT_BATCH( (pbox->y1 << 16) | pbox->x1 );
457
	 OUT_BATCH( (box.y1 << 16) | box.x1 );
436
	 OUT_BATCH( (pbox->y2 << 16) | pbox->x2 );
458
	 OUT_BATCH( (box.y2 << 16) | box.x2 );
437
459
438
	 if (intel->sarea->pf_current_page == 0) 
460
	 if (intel->sarea->pf_current_page == 0) 
439
	    OUT_BATCH( intelScreen->front.offset );
461
	    OUT_BATCH( intelScreen->front.offset );
440
	 else
462
	 else
441
	    OUT_BATCH( intelScreen->back.offset );			
463
	    OUT_BATCH( intelScreen->back.offset );			
442
464
443
	 OUT_BATCH( (pbox->y1 << 16) | pbox->x1 );
465
	 OUT_BATCH( (box.y1 << 16) | box.x1 );
444
	 OUT_BATCH( BR13 & 0xffff );
466
	 OUT_BATCH( BR13 & 0xffff );
445
467
446
	 if (intel->sarea->pf_current_page == 0) 
468
	 if (intel->sarea->pf_current_page == 0) 
Lines 454-467 Link Here
454
   intelFlushBatchLocked( intel, GL_TRUE, GL_TRUE, GL_TRUE );
476
   intelFlushBatchLocked( intel, GL_TRUE, GL_TRUE, GL_TRUE );
455
   UNLOCK_HARDWARE( intel );
477
   UNLOCK_HARDWARE( intel );
456
478
457
   intel->swap_count++;
479
   if (!rect)
458
   (*dri_interface->getUST)(&ust);
480
   {
459
   if (missed_target) {
481
       intel->swap_count++;
460
     intel->swap_missed_count++;
482
       (*dri_interface->getUST)(&ust);
461
     intel->swap_missed_ust = ust -  intel->swap_ust;
483
       if (missed_target) {
462
   }
484
	   intel->swap_missed_count++;
485
	   intel->swap_missed_ust = ust -  intel->swap_ust;
486
       }
463
   
487
   
464
   intel->swap_ust = ust;
488
       intel->swap_ust = ust;
489
   }
465
}
490
}
466
491
467
492
(-)src/mesa/drivers/dri/i915/intel_batchbuffer.h (-1 / +2 lines)
Lines 75-81 Link Here
75
extern GLuint *intelEmitInlinePrimitiveLocked(intelContextPtr intel, 
75
extern GLuint *intelEmitInlinePrimitiveLocked(intelContextPtr intel, 
76
					      int primitive, int dwords,
76
					      int primitive, int dwords,
77
					      int vertex_size);
77
					      int vertex_size);
78
extern void intelCopyBuffer( const __DRIdrawablePrivate *dpriv );
78
extern void intelCopyBuffer( const __DRIdrawablePrivate *dpriv,
79
			     const drm_clip_rect_t	*rect);
79
extern void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all,
80
extern void intelClearWithBlit(GLcontext *ctx, GLbitfield mask, GLboolean all,
80
			     GLint cx1, GLint cy1, GLint cw, GLint ch);
81
			     GLint cx1, GLint cy1, GLint cw, GLint ch);
81
82
(-)src/mesa/drivers/dri/i915/intel_context.c (-1 / +24 lines)
Lines 722-728 Link Here
722
	 if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */
722
	 if ( 0 /*intel->doPageFlip*/ ) { /* doPageFlip is never set !!! */
723
	    intelPageFlip( dPriv );
723
	    intelPageFlip( dPriv );
724
	 } else {
724
	 } else {
725
	    intelCopyBuffer( dPriv );
725
	     intelCopyBuffer( dPriv, NULL );
726
	 }
726
	 }
727
         if (screen->current_rotation != 0) {
727
         if (screen->current_rotation != 0) {
728
            intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT);
728
            intelRotateWindow(intel, dPriv, BUFFER_BIT_FRONT_LEFT);
Lines 734-739 Link Here
734
   }
734
   }
735
}
735
}
736
736
737
void intelCopySubBuffer( __DRIdrawablePrivate *dPriv,
738
			 int x, int y, int w, int h )
739
{
740
   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
741
      intelContextPtr intel;
742
      GLcontext *ctx;
743
      intel = (intelContextPtr) dPriv->driContextPriv->driverPrivate;
744
      ctx = &intel->ctx;
745
      if (ctx->Visual.doubleBufferMode) {
746
         intelScreenPrivate *screen = intel->intelScreen;
747
	 drm_clip_rect_t rect;
748
	 rect.x1 = x + dPriv->x;
749
	 rect.y1 = (dPriv->h - y - h) + dPriv->y;
750
	 rect.x2 = rect.x1 + w;
751
	 rect.y2 = rect.y1 + h;
752
	 _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
753
	 intelCopyBuffer( dPriv, &rect );
754
      }
755
   } else {
756
      /* XXX this shouldn't be an error but we can't handle it for now */
757
      fprintf(stderr, "%s: drawable has no context!\n", __FUNCTION__);
758
   }
759
}
737
760
738
void intelInitState( GLcontext *ctx )
761
void intelInitState( GLcontext *ctx )
739
{
762
{
(-)src/mesa/drivers/dri/i915/intel_screen.c (-1 / +3 lines)
Lines 341-346 Link Here
341
      (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
341
      (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
342
      (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
342
      (*glx_enable_extension)( psc, "GLX_SGI_make_current_read" );
343
      (*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
343
      (*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
344
      (*glx_enable_extension)( psc, "GLX_MESA_copy_sub_buffer" );
344
   }
345
   }
345
   
346
   
346
   sPriv->psc->allocateMemory = (void *) intelAllocateMemoryMESA;
347
   sPriv->psc->allocateMemory = (void *) intelAllocateMemoryMESA;
Lines 534-540 Link Here
534
   .GetMSC          = driGetMSC32,
535
   .GetMSC          = driGetMSC32,
535
   .WaitForMSC      = driWaitForMSC32,
536
   .WaitForMSC      = driWaitForMSC32,
536
   .WaitForSBC      = NULL,
537
   .WaitForSBC      = NULL,
537
   .SwapBuffersMSC  = NULL
538
   .SwapBuffersMSC  = NULL,
539
   .CopySubBuffer   = intelCopySubBuffer
538
};
540
};
539
541
540
542
(-)src/mesa/drivers/dri/i915/intel_screen.h (+3 lines)
Lines 106-109 Link Here
106
extern void
106
extern void
107
intelSwapBuffers(__DRIdrawablePrivate *dPriv);
107
intelSwapBuffers(__DRIdrawablePrivate *dPriv);
108
108
109
extern void
110
intelCopySubBuffer( __DRIdrawablePrivate *dPriv, int x, int y, int w, int h );
111
109
#endif
112
#endif
(-)src/mesa/drivers/dri/r200/r200_context.c (-1 / +25 lines)
Lines 637-643 Link Here
637
            r200PageFlip( dPriv );
637
            r200PageFlip( dPriv );
638
         }
638
         }
639
         else {
639
         else {
640
            r200CopyBuffer( dPriv );
640
	     r200CopyBuffer( dPriv, NULL );
641
         }
641
         }
642
      }
642
      }
643
   }
643
   }
Lines 647-652 Link Here
647
   }
647
   }
648
}
648
}
649
649
650
void
651
r200CopySubBuffer( __DRIdrawablePrivate *dPriv,
652
		   int x, int y, int w, int h )
653
{
654
   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
655
      r200ContextPtr rmesa;
656
      GLcontext *ctx;
657
      rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
658
      ctx = rmesa->glCtx;
659
      if (ctx->Visual.doubleBufferMode) {
660
	 drm_clip_rect_t rect;
661
	 rect.x1 = x + dPriv->x;
662
	 rect.y1 = (dPriv->h - y - h) + dPriv->y;
663
	 rect.x2 = rect.x1 + w;
664
	 rect.y2 = rect.y1 + h;
665
         _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
666
	 r200CopyBuffer( dPriv, &rect );
667
      }
668
   }
669
   else {
670
      /* XXX this shouldn't be an error but we can't handle it for now */
671
      _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
672
   }
673
}
650
674
651
/* Force the context `c' to be the current context and associate with it
675
/* Force the context `c' to be the current context and associate with it
652
 * buffer `b'.
676
 * buffer `b'.
(-)src/mesa/drivers/dri/r200/r200_context.h (+2 lines)
Lines 1002-1007 Link Here
1002
				    __DRIcontextPrivate *driContextPriv,
1002
				    __DRIcontextPrivate *driContextPriv,
1003
				    void *sharedContextPrivate);
1003
				    void *sharedContextPrivate);
1004
extern void r200SwapBuffers( __DRIdrawablePrivate *dPriv );
1004
extern void r200SwapBuffers( __DRIdrawablePrivate *dPriv );
1005
extern void r200CopySubBuffer( __DRIdrawablePrivate * dPriv,
1006
			       int x, int y, int w, int h );
1005
extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
1007
extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
1006
				  __DRIdrawablePrivate *driDrawPriv,
1008
				  __DRIdrawablePrivate *driDrawPriv,
1007
				  __DRIdrawablePrivate *driReadPriv );
1009
				  __DRIdrawablePrivate *driReadPriv );
(-)src/mesa/drivers/dri/r200/r200_ioctl.c (-15 / +41 lines)
Lines 420-426 Link Here
420
420
421
/* Copy the back color buffer to the front color buffer.
421
/* Copy the back color buffer to the front color buffer.
422
 */
422
 */
423
void r200CopyBuffer( const __DRIdrawablePrivate *dPriv )
423
void r200CopyBuffer( const __DRIdrawablePrivate *dPriv,
424
		      const drm_clip_rect_t	 *rect)
424
{
425
{
425
   r200ContextPtr rmesa;
426
   r200ContextPtr rmesa;
426
   GLint nbox, i, ret;
427
   GLint nbox, i, ret;
Lines 446-454 Link Here
446
    * request at a time.
447
    * request at a time.
447
    */
448
    */
448
   r200WaitForFrameCompletion( rmesa );
449
   r200WaitForFrameCompletion( rmesa );
449
   UNLOCK_HARDWARE( rmesa );
450
   if (!rect)
450
   driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
451
   {
451
   LOCK_HARDWARE( rmesa );
452
       UNLOCK_HARDWARE( rmesa );
453
       driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
454
       LOCK_HARDWARE( rmesa );
455
   }
452
456
453
   nbox = dPriv->numClipRects; /* must be in locked region */
457
   nbox = dPriv->numClipRects; /* must be in locked region */
454
458
Lines 459-466 Link Here
459
      GLint n = 0;
463
      GLint n = 0;
460
464
461
      for ( ; i < nr ; i++ ) {
465
      for ( ; i < nr ; i++ ) {
462
	 *b++ = box[i];
466
463
	 n++;
467
	  *b = box[i];
468
469
	  if (rect)
470
	  {
471
	     if (rect->x1 > b->x1)
472
		 b->x1 = rect->x1;
473
	     if (rect->y1 > b->y1)
474
		 b->y1 = rect->y1;
475
	     if (rect->x2 < b->x2)
476
		 b->x2 = rect->x2;
477
	     if (rect->y2 < b->y2)
478
		 b->y2 = rect->y2;
479
480
	     if (b->x1 < b->x2 && b->y1 < b->y2)
481
		 b++;
482
	  }
483
	  else
484
	      b++;
485
486
	  n++;
464
      }
487
      }
465
      rmesa->sarea->nbox = n;
488
      rmesa->sarea->nbox = n;
466
489
Lines 474-491 Link Here
474
   }
497
   }
475
498
476
   UNLOCK_HARDWARE( rmesa );
499
   UNLOCK_HARDWARE( rmesa );
477
   rmesa->hw.all_dirty = GL_TRUE;
500
   if (!rect)
501
   {
502
       rmesa->hw.all_dirty = GL_TRUE;
478
503
479
   rmesa->swap_count++;
504
       rmesa->swap_count++;
480
   (*dri_interface->getUST)( & ust );
505
       (*dri_interface->getUST)( & ust );
481
   if ( missed_target ) {
506
       if ( missed_target ) {
482
      rmesa->swap_missed_count++;
507
	   rmesa->swap_missed_count++;
483
      rmesa->swap_missed_ust = ust - rmesa->swap_ust;
508
	   rmesa->swap_missed_ust = ust - rmesa->swap_ust;
484
   }
509
       }
485
510
486
   rmesa->swap_ust = ust;
511
       rmesa->swap_ust = ust;
487
512
488
   sched_yield();
513
       sched_yield();
514
   }
489
}
515
}
490
516
491
void r200PageFlip( const __DRIdrawablePrivate *dPriv )
517
void r200PageFlip( const __DRIdrawablePrivate *dPriv )
(-)src/mesa/drivers/dri/r200/r200_ioctl.h (-1 / +2 lines)
Lines 90-96 Link Here
90
				    struct r200_dma_region *region,
90
				    struct r200_dma_region *region,
91
				    const char *caller );
91
				    const char *caller );
92
92
93
extern void r200CopyBuffer( const __DRIdrawablePrivate *drawable );
93
extern void r200CopyBuffer( const __DRIdrawablePrivate *drawable,
94
			    const drm_clip_rect_t      *rect);
94
extern void r200PageFlip( const __DRIdrawablePrivate *drawable );
95
extern void r200PageFlip( const __DRIdrawablePrivate *drawable );
95
extern void r200Flush( GLcontext *ctx );
96
extern void r200Flush( GLcontext *ctx );
96
extern void r200Finish( GLcontext *ctx );
97
extern void r200Finish( GLcontext *ctx );
(-)src/mesa/drivers/dri/r300/radeon_context.c (-1 / +26 lines)
Lines 229-235 Link Here
229
			if (radeon->doPageFlip) {
229
			if (radeon->doPageFlip) {
230
				radeonPageFlip(dPriv);
230
				radeonPageFlip(dPriv);
231
			} else {
231
			} else {
232
				radeonCopyBuffer(dPriv);
232
			    radeonCopyBuffer(dPriv, NULL);
233
			}
233
			}
234
		}
234
		}
235
	} else {
235
	} else {
Lines 239-244 Link Here
239
	}
239
	}
240
}
240
}
241
241
242
void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
243
			 int x, int y, int w, int h )
244
{
245
    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
246
	radeonContextPtr radeon;
247
	GLcontext *ctx;
248
249
	radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
250
	ctx = radeon->glCtx;
251
252
	if (ctx->Visual.doubleBufferMode) {
253
	    drm_clip_rect_t rect;
254
	    rect.x1 = x + dPriv->x;
255
	    rect.y1 = (dPriv->h - y - h) + dPriv->y;
256
	    rect.x2 = rect.x1 + w;
257
	    rect.y2 = rect.y1 + h;
258
	    _mesa_notifySwapBuffers(ctx);	/* flush pending rendering comands */
259
	    radeonCopyBuffer(dPriv, &rect);
260
	}
261
    } else {
262
	/* XXX this shouldn't be an error but we can't handle it for now */
263
	_mesa_problem(NULL, "%s: drawable has no context!",
264
		      __FUNCTION__);
265
    }
266
}
242
267
243
/* Force the context `c' to be the current context and associate with it
268
/* Force the context `c' to be the current context and associate with it
244
 * buffer `b'.
269
 * buffer `b'.
(-)src/mesa/drivers/dri/r300/radeon_context.h (+2 lines)
Lines 203-208 Link Here
203
#define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
203
#define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
204
204
205
extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
205
extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
206
extern void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
207
				int x, int y, int w, int h);
206
extern GLboolean radeonInitContext(radeonContextPtr radeon,
208
extern GLboolean radeonInitContext(radeonContextPtr radeon,
207
				   struct dd_function_table* functions,
209
				   struct dd_function_table* functions,
208
				   const __GLcontextModes * glVisual,
210
				   const __GLcontextModes * glVisual,
(-)src/mesa/drivers/dri/r300/radeon_ioctl.c (-17 / +42 lines)
Lines 145-151 Link Here
145
145
146
/* Copy the back color buffer to the front color buffer.
146
/* Copy the back color buffer to the front color buffer.
147
 */
147
 */
148
void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv)
148
void radeonCopyBuffer(const __DRIdrawablePrivate * dPriv,
149
		      const drm_clip_rect_t	 * rect)
149
{
150
{
150
	radeonContextPtr radeon;
151
	radeonContextPtr radeon;
151
	GLint nbox, i, ret;
152
	GLint nbox, i, ret;
Lines 174-183 Link Here
174
	 * request at a time.
175
	 * request at a time.
175
	 */
176
	 */
176
	radeonWaitForFrameCompletion(radeon);
177
	radeonWaitForFrameCompletion(radeon);
177
	UNLOCK_HARDWARE(radeon);
178
	if (!rect)
178
	driWaitForVBlank(dPriv, &radeon->vbl_seq, radeon->vblank_flags,
179
	{
179
			 &missed_target);
180
	    UNLOCK_HARDWARE(radeon);
180
	LOCK_HARDWARE(radeon);
181
	    driWaitForVBlank(dPriv, &radeon->vbl_seq, radeon->vblank_flags,
182
			     &missed_target);
183
	    LOCK_HARDWARE(radeon);
184
	}
181
185
182
	nbox = dPriv->numClipRects;	/* must be in locked region */
186
	nbox = dPriv->numClipRects;	/* must be in locked region */
183
187
Lines 187-195 Link Here
187
		drm_clip_rect_t *b = radeon->sarea->boxes;
191
		drm_clip_rect_t *b = radeon->sarea->boxes;
188
		GLint n = 0;
192
		GLint n = 0;
189
193
190
		for (; i < nr; i++) {
194
		for ( ; i < nr ; i++ ) {
191
			*b++ = box[i];
195
192
			n++;
196
		    *b = box[i];
197
198
		    if (rect)
199
		    {
200
			if (rect->x1 > b->x1)
201
			    b->x1 = rect->x1;
202
			if (rect->y1 > b->y1)
203
			    b->y1 = rect->y1;
204
			if (rect->x2 < b->x2)
205
			    b->x2 = rect->x2;
206
			if (rect->y2 < b->y2)
207
			    b->y2 = rect->y2;
208
209
			if (b->x1 < b->x2 && b->y1 < b->y2)
210
			    b++;
211
		    }
212
		    else
213
			b++;
214
215
		    n++;
193
		}
216
		}
194
		radeon->sarea->nbox = n;
217
		radeon->sarea->nbox = n;
195
218
Lines 204-225 Link Here
204
	}
227
	}
205
228
206
	UNLOCK_HARDWARE(radeon);
229
	UNLOCK_HARDWARE(radeon);
207
230
	if (!rect)
208
	if (IS_R200_CLASS(radeon->radeonScreen))
231
	{
232
	    if (IS_R200_CLASS(radeon->radeonScreen))
209
		((r200ContextPtr)radeon)->hw.all_dirty = GL_TRUE;
233
		((r200ContextPtr)radeon)->hw.all_dirty = GL_TRUE;
210
	else
234
	    else
211
		((r300ContextPtr)radeon)->hw.all_dirty = GL_TRUE;
235
		((r300ContextPtr)radeon)->hw.all_dirty = GL_TRUE;
212
236
213
	radeon->swap_count++;
237
	    radeon->swap_count++;
214
	(*dri_interface->getUST) (&ust);
238
	    (*dri_interface->getUST) (&ust);
215
	if (missed_target) {
239
	    if (missed_target) {
216
		radeon->swap_missed_count++;
240
		radeon->swap_missed_count++;
217
		radeon->swap_missed_ust = ust - radeon->swap_ust;
241
		radeon->swap_missed_ust = ust - radeon->swap_ust;
218
	}
242
	    }
219
243
220
	radeon->swap_ust = ust;
244
	    radeon->swap_ust = ust;
221
245
222
	sched_yield();
246
	    sched_yield();
247
	}
223
}
248
}
224
249
225
void radeonPageFlip(const __DRIdrawablePrivate * dPriv)
250
void radeonPageFlip(const __DRIdrawablePrivate * dPriv)
(-)src/mesa/drivers/dri/r300/radeon_ioctl.h (-1 / +2 lines)
Lines 44-50 Link Here
44
#include "r200_context.h"
44
#include "r200_context.h"
45
#include "radeon_drm.h"
45
#include "radeon_drm.h"
46
46
47
extern void radeonCopyBuffer(const __DRIdrawablePrivate * drawable);
47
extern void radeonCopyBuffer(const __DRIdrawablePrivate * drawable,
48
			     const drm_clip_rect_t	* rect);
48
extern void radeonPageFlip(const __DRIdrawablePrivate * drawable);
49
extern void radeonPageFlip(const __DRIdrawablePrivate * drawable);
49
extern void radeonFlush(GLcontext * ctx);
50
extern void radeonFlush(GLcontext * ctx);
50
extern void radeonFinish(GLcontext * ctx);
51
extern void radeonFinish(GLcontext * ctx);
(-)src/mesa/drivers/dri/radeon/radeon_context.c (-1 / +26 lines)
Lines 572-578 Link Here
572
            radeonPageFlip( dPriv );
572
            radeonPageFlip( dPriv );
573
         }
573
         }
574
         else {
574
         else {
575
            radeonCopyBuffer( dPriv );
575
	     radeonCopyBuffer( dPriv, NULL );
576
         }
576
         }
577
      }
577
      }
578
   }
578
   }
Lines 582-587 Link Here
582
   }
582
   }
583
}
583
}
584
584
585
void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
586
			 int x, int y, int w, int h )
587
{
588
    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
589
	radeonContextPtr radeon;
590
	GLcontext *ctx;
591
592
	radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
593
	ctx = radeon->glCtx;
594
595
	if (ctx->Visual.doubleBufferMode) {
596
	    drm_clip_rect_t rect;
597
	    rect.x1 = x + dPriv->x;
598
	    rect.y1 = (dPriv->h - y - h) + dPriv->y;
599
	    rect.x2 = rect.x1 + w;
600
	    rect.y2 = rect.y1 + h;
601
	    _mesa_notifySwapBuffers(ctx);	/* flush pending rendering comands */
602
	    radeonCopyBuffer(dPriv, &rect);
603
	}
604
    } else {
605
	/* XXX this shouldn't be an error but we can't handle it for now */
606
	_mesa_problem(NULL, "%s: drawable has no context!",
607
		      __FUNCTION__);
608
    }
609
}
585
610
586
/* Make context `c' the current context and bind it to the given
611
/* Make context `c' the current context and bind it to the given
587
 * drawing and reading surfaces.
612
 * drawing and reading surfaces.
(-)src/mesa/drivers/dri/radeon/radeon_context.h (+2 lines)
Lines 846-851 Link Here
846
				     __DRIcontextPrivate *driContextPriv,
846
				     __DRIcontextPrivate *driContextPriv,
847
				     void *sharedContextPrivate);
847
				     void *sharedContextPrivate);
848
extern void radeonSwapBuffers( __DRIdrawablePrivate *dPriv );
848
extern void radeonSwapBuffers( __DRIdrawablePrivate *dPriv );
849
extern void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
850
				int x, int y, int w, int h);
849
extern GLboolean radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
851
extern GLboolean radeonMakeCurrent( __DRIcontextPrivate *driContextPriv,
850
				    __DRIdrawablePrivate *driDrawPriv,
852
				    __DRIdrawablePrivate *driDrawPriv,
851
				    __DRIdrawablePrivate *driReadPriv );
853
				    __DRIdrawablePrivate *driReadPriv );
(-)src/mesa/drivers/dri/radeon/radeon_ioctl.c (-14 / +40 lines)
Lines 875-881 Link Here
875
875
876
/* Copy the back color buffer to the front color buffer.
876
/* Copy the back color buffer to the front color buffer.
877
 */
877
 */
878
void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv )
878
void radeonCopyBuffer( const __DRIdrawablePrivate *dPriv,
879
		       const drm_clip_rect_t	  *rect)
879
{
880
{
880
   radeonContextPtr rmesa;
881
   radeonContextPtr rmesa;
881
   GLint nbox, i, ret;
882
   GLint nbox, i, ret;
Lines 899-907 Link Here
899
    * request at a time.
900
    * request at a time.
900
    */
901
    */
901
   radeonWaitForFrameCompletion( rmesa );
902
   radeonWaitForFrameCompletion( rmesa );
902
   UNLOCK_HARDWARE( rmesa );
903
   if (!rect)
903
   driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
904
   {
904
   LOCK_HARDWARE( rmesa );
905
       UNLOCK_HARDWARE( rmesa );
906
       driWaitForVBlank( dPriv, & rmesa->vbl_seq, rmesa->vblank_flags, & missed_target );
907
       LOCK_HARDWARE( rmesa );
908
   }
905
909
906
   nbox = dPriv->numClipRects; /* must be in locked region */
910
   nbox = dPriv->numClipRects; /* must be in locked region */
907
911
Lines 912-919 Link Here
912
      GLint n = 0;
916
      GLint n = 0;
913
917
914
      for ( ; i < nr ; i++ ) {
918
      for ( ; i < nr ; i++ ) {
915
	 *b++ = box[i];
919
916
	 n++;
920
	  *b = box[i];
921
922
	  if (rect)
923
	  {
924
	      if (rect->x1 > b->x1)
925
		  b->x1 = rect->x1;
926
	      if (rect->y1 > b->y1)
927
		  b->y1 = rect->y1;
928
	      if (rect->x2 < b->x2)
929
		  b->x2 = rect->x2;
930
	      if (rect->y2 < b->y2)
931
		  b->y2 = rect->y2;
932
933
	      if (b->x1 < b->x2 && b->y1 < b->y2)
934
		  b++;
935
	  }
936
	  else
937
	      b++;
938
939
	  n++;
917
      }
940
      }
918
      rmesa->sarea->nbox = n;
941
      rmesa->sarea->nbox = n;
919
942
Lines 927-941 Link Here
927
   }
950
   }
928
951
929
   UNLOCK_HARDWARE( rmesa );
952
   UNLOCK_HARDWARE( rmesa );
930
   rmesa->swap_count++;
953
   if (!rect)
931
   (*dri_interface->getUST)( & ust );
954
   {
932
   if ( missed_target ) {
955
       rmesa->swap_count++;
933
      rmesa->swap_missed_count++;
956
       (*dri_interface->getUST)( & ust );
934
      rmesa->swap_missed_ust = ust - rmesa->swap_ust;
957
       if ( missed_target ) {
935
   }
958
	   rmesa->swap_missed_count++;
959
	   rmesa->swap_missed_ust = ust - rmesa->swap_ust;
960
       }
936
961
937
   rmesa->swap_ust = ust;
962
       rmesa->swap_ust = ust;
938
   rmesa->hw.all_dirty = GL_TRUE;
963
       rmesa->hw.all_dirty = GL_TRUE;
964
   }
939
}
965
}
940
966
941
void radeonPageFlip( const __DRIdrawablePrivate *dPriv )
967
void radeonPageFlip( const __DRIdrawablePrivate *dPriv )
(-)src/mesa/drivers/dri/radeon/radeon_ioctl.h (-1 / +2 lines)
Lines 87-93 Link Here
87
				    struct radeon_dma_region *region,
87
				    struct radeon_dma_region *region,
88
				    const char *caller );
88
				    const char *caller );
89
89
90
extern void radeonCopyBuffer( const __DRIdrawablePrivate *drawable );
90
extern void radeonCopyBuffer( const __DRIdrawablePrivate *drawable,
91
			      const drm_clip_rect_t	 *rect);
91
extern void radeonPageFlip( const __DRIdrawablePrivate *drawable );
92
extern void radeonPageFlip( const __DRIdrawablePrivate *drawable );
92
extern void radeonFlush( GLcontext *ctx );
93
extern void radeonFlush( GLcontext *ctx );
93
extern void radeonFinish( GLcontext *ctx );
94
extern void radeonFinish( GLcontext *ctx );
(-)src/mesa/drivers/dri/radeon/radeon_screen.c (-2 / +6 lines)
Lines 708-713 Link Here
708
      (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
708
      (*glx_enable_extension)( psc, "GLX_MESA_swap_frame_usage" );
709
      if (IS_R200_CLASS(screen))
709
      if (IS_R200_CLASS(screen))
710
	 (*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
710
	 (*glx_enable_extension)( psc, "GLX_MESA_allocate_memory" );
711
712
      (*glx_enable_extension)( psc, "GLX_MESA_copy_sub_buffer" );
711
   }
713
   }
712
714
713
#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
715
#if RADEON_COMMON && defined(RADEON_COMMON_FOR_R200)
Lines 915-921 Link Here
915
   .GetMSC          = driGetMSC32,
917
   .GetMSC          = driGetMSC32,
916
   .WaitForMSC      = driWaitForMSC32,
918
   .WaitForMSC      = driWaitForMSC32,
917
   .WaitForSBC      = NULL,
919
   .WaitForSBC      = NULL,
918
   .SwapBuffersMSC  = NULL
920
   .SwapBuffersMSC  = NULL,
921
   .CopySubBuffer   = radeonCopySubBuffer,
919
};
922
};
920
#else
923
#else
921
static const struct __DriverAPIRec r200API = {
924
static const struct __DriverAPIRec r200API = {
Lines 932-938 Link Here
932
   .GetMSC          = driGetMSC32,
935
   .GetMSC          = driGetMSC32,
933
   .WaitForMSC      = driWaitForMSC32,
936
   .WaitForMSC      = driWaitForMSC32,
934
   .WaitForSBC      = NULL,
937
   .WaitForSBC      = NULL,
935
   .SwapBuffersMSC  = NULL
938
   .SwapBuffersMSC  = NULL,
939
   .CopySubBuffer   = r200CopySubBuffer
936
};
940
};
937
#endif
941
#endif
938
942

Return to bug 157051