Merge branch 'upstream-gallium-0.1' into nouveau-gallium-0.1
[mesa.git] / src / mesa / drivers / dri / nouveau_winsys / nouveau_swapbuffers.c
index 57598f9cab9564c2b6521a1aa005266ac57b9c5e..91bf243f424bcd12041999875b09f905d0a02f82 100644 (file)
@@ -1,7 +1,10 @@
-#include "context.h"
+#include "main/glheader.h"
+#include "glapi/glthread.h"
+#include <GL/internal/glcore.h>
 
 #include "pipe/p_context.h"
 #include "state_tracker/st_public.h"
+#include "state_tracker/st_context.h"
 #include "state_tracker/st_cb_fbo.h"
 
 #include "nouveau_context.h"
@@ -14,8 +17,6 @@ nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
                    const drm_clip_rect_t *rect)
 {
        struct nouveau_context *nv = dPriv->driContextPriv->driverPrivate;
-       struct nouveau_screen *nv_screen = nv->nv_screen;
-       struct pipe_region *p_region = surf->region;
        drm_clip_rect_t *pbox;
        int nbox, i;
 
@@ -27,17 +28,7 @@ nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
        pbox = dPriv->pClipRects;
        nbox = dPriv->numClipRects;
 
-       BEGIN_RING(NvCtxSurf2D, 0x184, 2);
-       OUT_RELOCo(p_region->buffer, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
-       OUT_RING  (nv->channel->vram->handle);
-
-       BEGIN_RING(NvCtxSurf2D, 0x300, 4);
-       OUT_RING  ((p_region->cpp == 4) ? 6 : 4);
-       OUT_RING  ((nv_screen->front_pitch << 16) |
-                  (p_region->pitch * p_region->cpp));
-       OUT_RELOCl(p_region->buffer, 0, NOUVEAU_BO_VRAM | NOUVEAU_BO_RD);
-       OUT_RING  (nv_screen->front_offset);
-
+       nv->surface_copy_prep(nv, nv->frontbuffer, surf);
        for (i = 0; i < nbox; i++, pbox++) {
                int sx, sy, dx, dy, w, h;
 
@@ -48,10 +39,7 @@ nouveau_copy_buffer(__DRIdrawablePrivate *dPriv, struct pipe_surface *surf,
                w  = pbox->x2 - pbox->x1;
                h  = pbox->y2 - pbox->y1;
 
-               BEGIN_RING(NvImageBlit, 0x300, 3);
-               OUT_RING  ((sy << 16) | sx);
-               OUT_RING  ((dy << 16) | dx);
-               OUT_RING  (( h << 16) |  w);
+               nv->surface_copy(nv, dx, dy, sx, sy, w, h);
        }
 
        FIRE_RING();