sna: Tidy calling memcpy_from_tiled
authorChris Wilson <chris@chris-wilson.co.uk>
Sat, 28 Jun 2014 13:19:22 +0000 (14:19 +0100)
committerChris Wilson <chris@chris-wilson.co.uk>
Sun, 29 Jun 2014 05:57:04 +0000 (06:57 +0100)
Signed-off-by: Chris Wilson <chris@chris-wilson.co.uk>
src/sna/kgem.c
src/sna/kgem.h
src/sna/sna_accel.c
src/sna/sna_io.c

index 898f943..22aef25 100644 (file)
@@ -5968,6 +5968,7 @@ void *kgem_bo_map__cpu(struct kgem *kgem, struct kgem_bo *bo)
        assert(!bo->purged);
        assert(list_is_empty(&bo->list));
        assert(bo->proxy == NULL);
+       assert_tiling(kgem, bo);
 
        if (bo->map__cpu)
                return MAP(bo->map__cpu);
@@ -6086,6 +6087,8 @@ void kgem_bo_sync__cpu(struct kgem *kgem, struct kgem_bo *bo)
 {
        DBG(("%s: handle=%d\n", __FUNCTION__, bo->handle));
        assert(!bo->scanout);
+       assert_tiling(kgem, bo);
+
        kgem_bo_submit(kgem, bo);
 
        /* SHM pixmaps use proxies for subpage offsets */
@@ -6120,6 +6123,7 @@ void kgem_bo_sync__cpu_full(struct kgem *kgem, struct kgem_bo *bo, bool write)
 {
        DBG(("%s: handle=%d\n", __FUNCTION__, bo->handle));
        assert(!bo->scanout || !write);
+       assert_tiling(kgem, bo);
 
        if (write || bo->needs_flush)
                kgem_bo_submit(kgem, bo);
@@ -6165,6 +6169,7 @@ void kgem_bo_sync__gtt(struct kgem *kgem, struct kgem_bo *bo)
        DBG(("%s: handle=%d\n", __FUNCTION__, bo->handle));
        assert(bo->refcnt);
        assert(bo->proxy == NULL);
+       assert_tiling(kgem, bo);
 
        kgem_bo_submit(kgem, bo);
 
index e66bffb..be9b7e8 100644 (file)
@@ -787,6 +787,11 @@ memcpy_to_tiled_x(struct kgem *kgem,
                  int16_t dst_x, int16_t dst_y,
                  uint16_t width, uint16_t height)
 {
+       assert(kgem->memcpy_to_tiled_x);
+       assert(src_x >= 0 && src_y >= 0);
+       assert(dst_x >= 0 && dst_y >= 0);
+       assert(8*src_stride >= (src_x+width) * bpp);
+       assert(8*dst_stride >= (dst_x+width) * bpp);
        return kgem->memcpy_to_tiled_x(src, dst, bpp,
                                       src_stride, dst_stride,
                                       src_x, src_y,
@@ -802,6 +807,11 @@ memcpy_from_tiled_x(struct kgem *kgem,
                    int16_t dst_x, int16_t dst_y,
                    uint16_t width, uint16_t height)
 {
+       assert(kgem->memcpy_from_tiled_x);
+       assert(src_x >= 0 && src_y >= 0);
+       assert(dst_x >= 0 && dst_y >= 0);
+       assert(8*src_stride >= (src_x+width) * bpp);
+       assert(8*dst_stride >= (dst_x+width) * bpp);
        return kgem->memcpy_from_tiled_x(src, dst, bpp,
                                         src_stride, dst_stride,
                                         src_x, src_y,
index a559907..9f5c0b4 100644 (file)
@@ -1693,30 +1693,32 @@ static inline bool gpu_bo_download(struct sna *sna,
                return false;
 
        if (priv->gpu_bo->tiling) {
+               int bpp = priv->pixmap->drawable.bitsPerPixel;
+               void *dst = priv->pixmap->devPrivate.ptr;
+               int dst_pitch = priv->pixmap->devKind;
+
                DBG(("%s: download through a tiled CPU map\n", __FUNCTION__));
                do {
                        DBG(("%s: box (%d, %d), (%d, %d)\n",
                             __FUNCTION__, box->x1, box->y1, box->x2, box->y2));
-                       memcpy_from_tiled_x(&sna->kgem, src,
-                                           priv->pixmap->devPrivate.ptr,
-                                           priv->pixmap->drawable.bitsPerPixel,
-                                           priv->gpu_bo->pitch,
-                                           priv->pixmap->devKind,
+                       memcpy_from_tiled_x(&sna->kgem, src, dst, bpp,
+                                           priv->gpu_bo->pitch, dst_pitch,
                                            box->x1, box->y1,
                                            box->x1, box->y1,
                                            box->x2 - box->x1, box->y2 - box->y1);
                        box++;
                } while (--n);
        } else {
+               int bpp = priv->pixmap->drawable.bitsPerPixel;
+               void *dst = priv->pixmap->devPrivate.ptr;
+               int dst_pitch = priv->pixmap->devKind;
+
                DBG(("%s: download through a linear CPU map\n", __FUNCTION__));
                do {
                        DBG(("%s: box (%d, %d), (%d, %d)\n",
                             __FUNCTION__, box->x1, box->y1, box->x2, box->y2));
-                       memcpy_blt(src,
-                                  priv->pixmap->devPrivate.ptr,
-                                  priv->pixmap->drawable.bitsPerPixel,
-                                  priv->gpu_bo->pitch,
-                                  priv->pixmap->devKind,
+                       memcpy_blt(src, dst, bpp,
+                                  priv->gpu_bo->pitch, dst_pitch,
                                   box->x1, box->y1,
                                   box->x1, box->y1,
                                   box->x2 - box->x1, box->y2 - box->y1);
@@ -4934,6 +4936,10 @@ sna_put_zpixmap_blt(DrawablePtr drawable, GCPtr gc, RegionPtr region,
        get_drawable_deltas(drawable, pixmap, &dx, &dy);
        x += dx + drawable->x;
        y += dy + drawable->y;
+       assert(region->extents.x1 >= x);
+       assert(region->extents.y1 >= y);
+       assert(region->extents.x2 <= x + w);
+       assert(region->extents.y2 <= y + h);
 
        if (try_upload__fast(pixmap, region, x, y, w, h, bits, stride))
                return true;
index f464dce..9e175a7 100644 (file)
@@ -118,7 +118,6 @@ read_boxes_inplace__cpu(struct kgem *kgem,
                return false;
 
        if (bo->tiling == I915_TILING_X) {
-               assert(kgem->memcpy_from_tiled_x);
                do {
                        memcpy_from_tiled_x(kgem, src, dst, bpp, src_pitch, dst_pitch,
                                            box->x1, box->y1,