nouveau: track last validated offsets, so we know when relocs can be avoided.
authorBen Skeggs <skeggsb@gmail.com>
Wed, 26 Dec 2007 19:21:13 +0000 (06:21 +1100)
committerBen Skeggs <skeggsb@gmail.com>
Wed, 26 Dec 2007 19:22:28 +0000 (06:22 +1100)
src/mesa/drivers/dri/nouveau_winsys/nouveau_bo.c
src/mesa/drivers/dri/nouveau_winsys/nouveau_drmif.h
src/mesa/drivers/dri/nouveau_winsys/nouveau_pushbuf.c

index 08d38c5..288674f 100644 (file)
@@ -348,8 +348,8 @@ nouveau_bo_validate_user(struct nouveau_channel *chan, struct nouveau_bo *bo,
 
        memcpy(nvdev->sa_map + r->start, nvbo->sysmem, bo->size);
 
-       nvbo->base.offset = nvdev->sa.offset + r->start;
-       nvbo->base.flags = NOUVEAU_BO_GART;
+       nvbo->offset = nvdev->sa.offset + r->start;
+       nvbo->flags = NOUVEAU_BO_GART;
        return 0;
 }
 
@@ -371,11 +371,11 @@ nouveau_bo_validate_bo(struct nouveau_channel *chan, struct nouveau_bo *bo,
                nouveau_bo_upload(nvbo);
        }
 
-       nvbo->base.offset = nvbo->drm.offset;
+       nvbo->offset = nvbo->drm.offset;
        if (nvbo->drm.flags & (NOUVEAU_MEM_AGP | NOUVEAU_MEM_PCI))
-               nvbo->base.flags = NOUVEAU_BO_GART;
+               nvbo->flags = NOUVEAU_BO_GART;
        else
-               nvbo->base.flags = NOUVEAU_BO_VRAM;
+               nvbo->flags = NOUVEAU_BO_VRAM;
 
        return 0;
 }
index 4b42baf..3e88686 100644 (file)
@@ -251,6 +251,9 @@ struct nouveau_bo_priv {
        int user;
 
        int refcount;
+
+       uint64_t offset;
+       uint64_t flags;
 };
 #define nouveau_bo(n) ((struct nouveau_bo_priv *)(n))
 
index 020b1e0..a34a5c1 100644 (file)
@@ -131,6 +131,16 @@ nouveau_pushbuf_flush(struct nouveau_channel *chan, unsigned min)
                ret = nouveau_bo_validate(chan, bo, fence, pbbo->flags);
                assert (ret == 0);
 
+               if (bo->offset == nouveau_bo(bo)->offset &&
+                   bo->flags == nouveau_bo(bo)->flags) {
+                       /*XXX: could avoid reloc in this case, except with the
+                        *     current design we'd confuse the GPU quite a bit
+                        *     if we did this.  Will fix soon.
+                        */
+               }
+               bo->offset = nouveau_bo(bo)->offset;
+               bo->flags = nouveau_bo(bo)->flags;
+
                while ((r = ptr_to_pbrel(pbbo->relocs))) {
                        uint32_t push;