intel: Do not access pbo's buffer directly when attaching.
authorChia-I Wu <olvaffe@gmail.com>
Thu, 18 Jun 2009 05:42:24 +0000 (13:42 +0800)
committerEric Anholt <eric@anholt.net>
Fri, 19 Jun 2009 23:43:45 +0000 (16:43 -0700)
pbo might be system buffer based or attached to another region.  Call
intel_bufferobj_buffer to make sure pbo has a buffer of its own.

Signed-off-by: Chia-I Wu <olvaffe@gmail.com>
Signed-off-by: Eric Anholt <eric@anholt.net>
src/mesa/drivers/dri/intel/intel_regions.c

index 857e5ba85f1627b73b1d0eb578e7fa015928cf8e..e142020d16977df8f6fb5d963ab0813caecaa2ca 100644 (file)
@@ -427,6 +427,8 @@ intel_region_attach_pbo(struct intel_context *intel,
                         struct intel_region *region,
                         struct intel_buffer_object *pbo)
 {
+   dri_bo *buffer;
+
    if (region->pbo == pbo)
       return;
 
@@ -447,10 +449,13 @@ intel_region_attach_pbo(struct intel_context *intel,
       region->buffer = NULL;
    }
 
+   /* make sure pbo has a buffer of its own */
+   buffer = intel_bufferobj_buffer(intel, pbo, INTEL_WRITE_FULL);
+
    region->pbo = pbo;
    region->pbo->region = region;
-   dri_bo_reference(pbo->buffer);
-   region->buffer = pbo->buffer;
+   dri_bo_reference(buffer);
+   region->buffer = buffer;
 }