radeon/r200/r300: consolidate swap buffers
authorDave Airlie <airlied@redhat.com>
Wed, 14 Jan 2009 03:38:12 +0000 (13:38 +1000)
committerDave Airlie <airlied@redhat.com>
Wed, 14 Jan 2009 03:38:12 +0000 (13:38 +1000)
12 files changed:
src/mesa/drivers/dri/r200/r200_context.c
src/mesa/drivers/dri/r200/r200_context.h
src/mesa/drivers/dri/r300/r300_context.c
src/mesa/drivers/dri/r300/radeon_context.c
src/mesa/drivers/dri/r300/radeon_context.h
src/mesa/drivers/dri/radeon/common_context.h
src/mesa/drivers/dri/radeon/common_lock.c
src/mesa/drivers/dri/radeon/common_misc.c
src/mesa/drivers/dri/radeon/common_misc.h
src/mesa/drivers/dri/radeon/radeon_context.c
src/mesa/drivers/dri/radeon/radeon_context.h
src/mesa/drivers/dri/radeon/radeon_screen.c

index 85e508616b493aae592fa03d6c216ae05d9c960f..fd41171de818baf281fbce806b0cf4d105c3cb2d 100644 (file)
@@ -640,58 +640,6 @@ void r200DestroyContext( __DRIcontextPrivate *driContextPriv )
    }
 }
 
-
-
-
-void
-r200SwapBuffers( __DRIdrawablePrivate *dPriv )
-{
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      r200ContextPtr rmesa;
-      GLcontext *ctx;
-      rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
-      ctx = rmesa->radeon.glCtx;
-      if (ctx->Visual.doubleBufferMode) {
-         _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
-         if ( rmesa->radeon.doPageFlip ) {
-            r200PageFlip( dPriv );
-         }
-         else {
-            radeonCopyBuffer( dPriv, NULL );
-         }
-      }
-   }
-   else {
-      /* XXX this shouldn't be an error but we can't handle it for now */
-      _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
-   }
-}
-
-void
-r200CopySubBuffer( __DRIdrawablePrivate *dPriv,
-                  int x, int y, int w, int h )
-{
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      r200ContextPtr rmesa;
-      GLcontext *ctx;
-      rmesa = (r200ContextPtr) dPriv->driContextPriv->driverPrivate;
-      ctx = rmesa->radeon.glCtx;
-      if (ctx->Visual.doubleBufferMode) {
-        drm_clip_rect_t rect;
-        rect.x1 = x + dPriv->x;
-        rect.y1 = (dPriv->h - y - h) + dPriv->y;
-        rect.x2 = rect.x1 + w;
-        rect.y2 = rect.y1 + h;
-         _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
-        radeonCopyBuffer( dPriv, &rect );
-      }
-   }
-   else {
-      /* XXX this shouldn't be an error but we can't handle it for now */
-      _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
-   }
-}
-
 /* Force the context `c' to be the current context and associate with it
  * buffer `b'.
  */
index 94f9b86d2f224a1c352c326fc151e6e05d05faae..c1a68aa69411fe13147a781d8b07e05b47b23b18 100644 (file)
@@ -677,9 +677,6 @@ extern void r200DestroyContext( __DRIcontextPrivate *driContextPriv );
 extern GLboolean r200CreateContext( const __GLcontextModes *glVisual,
                                    __DRIcontextPrivate *driContextPriv,
                                    void *sharedContextPrivate);
-extern void r200SwapBuffers( __DRIdrawablePrivate *dPriv );
-extern void r200CopySubBuffer( __DRIdrawablePrivate * dPriv,
-                              int x, int y, int w, int h );
 extern GLboolean r200MakeCurrent( __DRIcontextPrivate *driContextPriv,
                                  __DRIdrawablePrivate *driDrawPriv,
                                  __DRIdrawablePrivate *driReadPriv );
@@ -688,13 +685,8 @@ extern GLboolean r200UnbindContext( __DRIcontextPrivate *driContextPriv );
 /* ================================================================
  * Debugging:
  */
-#define DO_DEBUG               1
 
-#if DO_DEBUG
-extern int R200_DEBUG;
-#else
-#define R200_DEBUG             0
-#endif
+#define R200_DEBUG RADEON_DEBUG
 
 
 
index 3b8ba855bb57da259d532d10884bcc8e94d7f323..974cf5fcef6df31db7c767d7fabdedaa1e18db89 100644 (file)
@@ -215,6 +215,7 @@ static void r300_init_vtbl(radeonContextPtr radeon)
    radeon->vtbl.update_viewport_offset = r300UpdateViewportOffset;
    radeon->vtbl.flush = r300_vtbl_flush;
    radeon->vtbl.set_all_dirty = r300_vtbl_set_all_dirty;
+   radeon->vtbl.update_draw_buffer = r300UpdateDrawBuffer;
 }
 
 
index 092562b8f97c5468baa12f87726729404fde010b..96478640cc196f9862e4fe76201dacdfe52c78fe 100644 (file)
@@ -248,60 +248,6 @@ void radeonCleanupContext(radeonContextPtr radeon)
     }
 }
 
-
-/**
- * Swap front and back buffer.
- */
-void radeonSwapBuffers(__DRIdrawablePrivate * dPriv)
-{
-       if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-               radeonContextPtr radeon;
-               GLcontext *ctx;
-
-               radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-               ctx = radeon->glCtx;
-
-               if (ctx->Visual.doubleBufferMode) {
-                       _mesa_notifySwapBuffers(ctx);/* flush pending rendering comands */
-                       if (radeon->doPageFlip) {
-                               radeonPageFlip(dPriv);
-                       } else {
-                           radeonCopyBuffer(dPriv, NULL);
-                       }
-               }
-       } else {
-               /* XXX this shouldn't be an error but we can't handle it for now */
-               _mesa_problem(NULL, "%s: drawable has no context!",
-                             __FUNCTION__);
-       }
-}
-
-void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
-                        int x, int y, int w, int h )
-{
-    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-       radeonContextPtr radeon;
-       GLcontext *ctx;
-
-       radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-       ctx = radeon->glCtx;
-
-       if (ctx->Visual.doubleBufferMode) {
-           drm_clip_rect_t rect;
-           rect.x1 = x + dPriv->x;
-           rect.y1 = (dPriv->h - y - h) + dPriv->y;
-           rect.x2 = rect.x1 + w;
-           rect.y2 = rect.y1 + h;
-           _mesa_notifySwapBuffers(ctx);       /* flush pending rendering comands */
-           radeonCopyBuffer(dPriv, &rect);
-       }
-    } else {
-       /* XXX this shouldn't be an error but we can't handle it for now */
-       _mesa_problem(NULL, "%s: drawable has no context!",
-                     __FUNCTION__);
-    }
-}
-
 static void
 radeon_make_kernel_renderbuffer_current(radeonContextPtr radeon,
                                        GLframebuffer *draw)
index d46a2d20ff3cd7c65e6ed9abb4f9111e056a1c29..be21a8cfbc9fb93bc654e9543a54ed87b99af49a 100644 (file)
@@ -89,7 +89,6 @@ extern void radeonTclFallback(GLcontext * ctx, GLuint bit, GLboolean mode);
 #endif
 
 
-extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
 extern void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
                                int x, int y, int w, int h);
 extern GLboolean radeonInitContext(radeonContextPtr radeon,
index d157c93dcb2a6bb722a1e015ee705a8b57bec8e2..e4d210392c48a4ab3941c8e8c5cb0823f262db4e 100644 (file)
@@ -319,4 +319,15 @@ struct radeon_context {
 
 #define RADEON_CONTEXT(glctx) ((radeonContextPtr)(ctx->DriverCtx))
 
+/* ================================================================
+ * Debugging:
+ */
+#define DO_DEBUG               1
+
+#if DO_DEBUG
+extern int RADEON_DEBUG;
+#else
+#define RADEON_DEBUG           0
+#endif
+
 #endif
index fe38fc95bc921baa29ad181f4cf4255fa2095f8b..d983e8ce926c584b6f0d0df3b3786d67c4b04187 100644 (file)
@@ -46,6 +46,7 @@ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 #include "radeon_screen.h"
 #include "common_context.h"
 #include "common_lock.h"
+#include "common_misc.h"
 
 #include "drirenderbuffer.h"
 
@@ -65,7 +66,7 @@ void radeonUpdatePageFlipping(radeonContextPtr rmesa)
 
        rmesa->doPageFlip = rmesa->sarea->pfState;
        if (rmesa->glCtx->WinSysDrawBuffer) {
-               r300UpdateDrawBuffer(rmesa->glCtx);
+               rmesa->vtbl.update_draw_buffer(rmesa->glCtx);
        }
 
        use_back = rmesa->glCtx->DrawBuffer ?
index b14ca8b51b26530643bb8b1ef42dee4b0d336489..eab9cc74e32b4ed98624234a1005681cee2877a7 100644 (file)
@@ -344,9 +344,9 @@ void radeonCopyBuffer( __DRIdrawablePrivate *dPriv,
    ctx = (GLcontext *) dPriv->driContextPriv->driverPrivate;
    rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
 
-///   if ( RADEON_DEBUG & DEBUG_IOCTL ) {
-//      fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, (void *) rmesa->glCtx );
-//   }
+   if ( RADEON_DEBUG & DEBUG_IOCTL ) {
+      fprintf( stderr, "\n%s( %p )\n\n", __FUNCTION__, (void *) rmesa->glCtx );
+   }
 
    rmesa->vtbl.flush(ctx);
    LOCK_HARDWARE( rmesa );
@@ -437,16 +437,14 @@ void radeonPageFlip( __DRIdrawablePrivate *dPriv )
    assert(dPriv->driContextPriv->driverPrivate);
 
    rmesa = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-  rrb = (void *)fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
+   rrb = (void *)fb->Attachment[BUFFER_FRONT_LEFT].Renderbuffer;
 
    psp = dPriv->driScreenPriv;
 
-#if 0
    if ( RADEON_DEBUG & DEBUG_IOCTL ) {
       fprintf(stderr, "%s: pfCurrentPage: %d\n", __FUNCTION__,
              rmesa->sarea->pfCurrentPage);
    }
-#endif
 
    rmesa->vtbl.flush(rmesa->glCtx);
 
@@ -525,3 +523,57 @@ void radeon_common_finish(GLcontext * ctx)
                radeonWaitForIdle(radeon);
        }
 }
+
+/**
+ * Swap front and back buffer.
+ */
+void radeonSwapBuffers(__DRIdrawablePrivate * dPriv)
+{
+       if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+               radeonContextPtr radeon;
+               GLcontext *ctx;
+
+               radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+               ctx = radeon->glCtx;
+
+               if (ctx->Visual.doubleBufferMode) {
+                       _mesa_notifySwapBuffers(ctx);/* flush pending rendering comands */
+                       if (radeon->doPageFlip) {
+                               radeonPageFlip(dPriv);
+                       } else {
+                               radeonCopyBuffer(dPriv, NULL);
+                       }
+               }
+       } else {
+               /* XXX this shouldn't be an error but we can't handle it for now */
+               _mesa_problem(NULL, "%s: drawable has no context!",
+                             __FUNCTION__);
+       }
+}
+
+void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
+                        int x, int y, int w, int h )
+{
+    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
+       radeonContextPtr radeon;
+       GLcontext *ctx;
+
+       radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
+       ctx = radeon->glCtx;
+
+       if (ctx->Visual.doubleBufferMode) {
+           drm_clip_rect_t rect;
+           rect.x1 = x + dPriv->x;
+           rect.y1 = (dPriv->h - y - h) + dPriv->y;
+           rect.x2 = rect.x1 + w;
+           rect.y2 = rect.y1 + h;
+           _mesa_notifySwapBuffers(ctx);       /* flush pending rendering comands */
+           radeonCopyBuffer(dPriv, &rect);
+       }
+    } else {
+       /* XXX this shouldn't be an error but we can't handle it for now */
+       _mesa_problem(NULL, "%s: drawable has no context!",
+                     __FUNCTION__);
+    }
+}
+
index 27e869d4bbbc1196d758b5f4bc2fdc69e5418130..cc4832c75ee0f1aa4b0450baf587991171273c4e 100644 (file)
@@ -11,5 +11,10 @@ void radeonCopyBuffer( __DRIdrawablePrivate *dPriv,
                       const drm_clip_rect_t      *rect);
 void radeonPageFlip( __DRIdrawablePrivate *dPriv );
 void radeon_common_finish(GLcontext * ctx);
+void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
+void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
+                        int x, int y, int w, int h );
+
+void radeonUpdatePageFlipping(radeonContextPtr rmesa);
 
 #endif
index ab2002cd90335ebbadcb9e39e0c25f388d4550cd..1adef7c7020c65deb2c6d05f6addd2f231f874d8 100644 (file)
@@ -563,61 +563,6 @@ void radeonDestroyContext( __DRIcontextPrivate *driContextPriv )
    }
 }
 
-
-
-
-void
-radeonSwapBuffers( __DRIdrawablePrivate *dPriv )
-{
-
-   if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-      r100ContextPtr rmesa;
-      GLcontext *ctx;
-      rmesa = (r100ContextPtr) dPriv->driContextPriv->driverPrivate;
-      ctx = rmesa->radeon.glCtx;
-      if (ctx->Visual.doubleBufferMode) {
-         _mesa_notifySwapBuffers( ctx );  /* flush pending rendering comands */
-
-         if ( rmesa->radeon.doPageFlip ) {
-            radeonPageFlip( dPriv );
-         }
-         else {
-            radeonCopyBuffer( dPriv, NULL );
-         }
-      }
-   }
-   else {
-      /* XXX this shouldn't be an error but we can't handle it for now */
-      _mesa_problem(NULL, "%s: drawable has no context!", __FUNCTION__);
-   }
-}
-
-void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
-                        int x, int y, int w, int h )
-{
-    if (dPriv->driContextPriv && dPriv->driContextPriv->driverPrivate) {
-       radeonContextPtr radeon;
-       GLcontext *ctx;
-
-       radeon = (radeonContextPtr) dPriv->driContextPriv->driverPrivate;
-       ctx = radeon->glCtx;
-
-       if (ctx->Visual.doubleBufferMode) {
-           drm_clip_rect_t rect;
-           rect.x1 = x + dPriv->x;
-           rect.y1 = (dPriv->h - y - h) + dPriv->y;
-           rect.x2 = rect.x1 + w;
-           rect.y2 = rect.y1 + h;
-           _mesa_notifySwapBuffers(ctx);       /* flush pending rendering comands */
-           radeonCopyBuffer(dPriv, &rect);
-       }
-    } else {
-       /* XXX this shouldn't be an error but we can't handle it for now */
-       _mesa_problem(NULL, "%s: drawable has no context!",
-                     __FUNCTION__);
-    }
-}
-
 /* Make context `c' the current context and bind it to the given
  * drawing and reading surfaces.
  */
index 0ca49cc078dd976e9621d55607c73db1868d59db..dedc36260403d64c326bd6c7a883b4a524dfef5f 100644 (file)
@@ -476,23 +476,11 @@ extern void radeonDestroyContext(__DRIcontextPrivate * driContextPriv);
 extern GLboolean radeonCreateContext(const __GLcontextModes * glVisual,
                                     __DRIcontextPrivate * driContextPriv,
                                     void *sharedContextPrivate);
-extern void radeonSwapBuffers(__DRIdrawablePrivate * dPriv);
-extern void radeonCopySubBuffer(__DRIdrawablePrivate * dPriv,
-                               int x, int y, int w, int h);
 extern GLboolean radeonMakeCurrent(__DRIcontextPrivate * driContextPriv,
                                   __DRIdrawablePrivate * driDrawPriv,
                                   __DRIdrawablePrivate * driReadPriv);
 extern GLboolean radeonUnbindContext(__DRIcontextPrivate * driContextPriv);
 
-/* ================================================================
- * Debugging:
- */
-#define DO_DEBUG               1
 
-#if DO_DEBUG
-extern int RADEON_DEBUG;
-#else
-#define RADEON_DEBUG           0
-#endif
 
 #endif                         /* __RADEON_CONTEXT_H__ */
index 0b64d6f4ac5f23da9152380142c534a2805a27e5..c099d0ee349e3abef74a6061ae3e2aae2d9fdcb2 100644 (file)
@@ -1620,7 +1620,7 @@ const struct __DriverAPIRec driDriverAPI = {
    .DestroyContext  = r200DestroyContext,
    .CreateBuffer    = radeonCreateBuffer,
    .DestroyBuffer   = radeonDestroyBuffer,
-   .SwapBuffers     = r200SwapBuffers,
+   .SwapBuffers     = radeonSwapBuffers,
    .MakeCurrent     = r200MakeCurrent,
    .UnbindContext   = r200UnbindContext,
    .GetSwapInfo     = getSwapInfo,
@@ -1628,7 +1628,7 @@ const struct __DriverAPIRec driDriverAPI = {
    .WaitForMSC      = driWaitForMSC32,
    .WaitForSBC      = NULL,
    .SwapBuffersMSC  = NULL,
-   .CopySubBuffer   = r200CopySubBuffer,
+   .CopySubBuffer   = radeonCopySubBuffer,
 };
 #endif