r600g: add back reference check when mapping buffer
authorJerome Glisse <jglisse@redhat.com>
Mon, 20 Sep 2010 21:21:37 +0000 (17:21 -0400)
committerJerome Glisse <jglisse@redhat.com>
Mon, 20 Sep 2010 21:21:37 +0000 (17:21 -0400)
Signed-off-by: Jerome Glisse <jglisse@redhat.com>
src/gallium/targets/dri-r600/target.c
src/gallium/winsys/r600/drm/radeon_bo_pb.c

index eb268d5bc0110ee69bd6db6b63a36aa24a46fa29..2c1b2f5be45c79a7d106bd71de6fe08112ea8a3e 100644 (file)
@@ -4,7 +4,7 @@
 #include "r600/drm/r600_drm_public.h"
 #include "r600/r600_public.h"
 
-#if 1
+#if 0
 static struct pipe_screen *
 create_screen(int fd)
 {
index 148cf6d81d202a3fbe6981a72dc31acc878947d2..897938c2cafd4dba08f758d870633df1f286cd25 100644 (file)
@@ -55,7 +55,6 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
        struct radeon_bo_pb *buf = radeon_bo_pb(_buf);
        struct pipe_context *pctx = ctx;
 
-//printf("%s:%d ************************************************\n", __func__, __LINE__);
        if (flags & PB_USAGE_UNSYNCHRONIZED) {
                if (!buf->bo->data && radeon_bo_map(buf->mgr->radeon, buf->bo)) {
                        return NULL;
@@ -64,11 +63,13 @@ radeon_bo_pb_map_internal(struct pb_buffer *_buf,
                return buf->bo->data;
        }
 
-       if (flags & PB_USAGE_DONTBLOCK) {
-               return NULL;
-       }
-       if (ctx) {
-               pctx->flush(pctx, 0, NULL);
+       if (p_atomic_read(&buf->bo->reference.count) > 1) {
+               if (flags & PB_USAGE_DONTBLOCK) {
+                       return NULL;
+               }
+               if (ctx) {
+                       pctx->flush(pctx, 0, NULL);
+               }
        }
 
        if (flags & PB_USAGE_DONTBLOCK) {