aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThomas White <taw@bitwiz.org.uk>2009-08-16 18:07:57 +0100
committerThomas White <taw@bitwiz.org.uk>2010-05-23 09:51:34 +0200
commit88d59f6ff3769aa4e0f2a221ecea22fd86413115 (patch)
tree6117b64b5f08b008dd86d456374759662fe59b54
parentd852c19efb9551ccfcf6fc330f9d816e8df359a8 (diff)
Map counting fixes
-rw-r--r--glamo/glamo_bo_gem.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/glamo/glamo_bo_gem.c b/glamo/glamo_bo_gem.c
index 048f477c..e76f9aa6 100644
--- a/glamo/glamo_bo_gem.c
+++ b/glamo/glamo_bo_gem.c
@@ -174,6 +174,10 @@ static struct glamo_bo *bo_unref(struct glamo_bo *bo)
return bo;
}
if (bo_gem->map_count) {
+ fprintf(stderr, "Map count for %p isn't zero (=%i),"
+ " so I am unmapping it (%p, %i)\n",
+ bo_gem, bo_gem->map_count, bo->virtual,
+ bo->size);
munmap(bo->virtual, bo->size);
}
@@ -224,6 +228,7 @@ static int bo_map(struct glamo_bo *bo, int write)
strerror(errno));
return errno;
}
+ bo_gem->map_count++;
}
return 0;
@@ -233,6 +238,12 @@ static int bo_unmap(struct glamo_bo *bo)
{
struct glamo_bo_gem *bo_gem = (struct glamo_bo_gem*)bo;
+ if ( bo_gem->map_count == 0 ) {
+ fprintf(stderr, "Not unmapping %p, because its map count"
+ " is already zero.\n", bo_gem);
+ return 0;
+ }
+
if (--bo_gem->map_count > 0) {
return 0;
}