intel: Use new drm_intel_bo_references() to avoid flushing.
authorEric Anholt <eric@anholt.net>
Fri, 2 Oct 2009 00:53:12 +0000 (17:53 -0700)
committerEric Anholt <eric@anholt.net>
Fri, 9 Oct 2009 00:12:23 +0000 (17:12 -0700)
src/mesa/drivers/dri/intel/intel_buffer_objects.c
src/mesa/drivers/dri/intel/intel_tex_image.c

index a0225936c81648a133c1eec15b2ab95f2185b527..ea9d5a6276e50e892b3226be304ceb86d1292839 100644 (file)
@@ -209,7 +209,8 @@ intel_bufferobj_subdata(GLcontext * ctx,
       memcpy((char *)intel_obj->sys_buffer + offset, data, size);
    else {
       /* Flush any existing batchbuffer that might reference this data. */
-      intelFlush(ctx);
+      if (drm_intel_bo_references(intel->batch->buf, intel_obj->buffer))
+        intelFlush(ctx);
 
       dri_bo_subdata(intel_obj->buffer, offset, size, data);
    }
@@ -257,10 +258,9 @@ intel_bufferobj_map(GLcontext * ctx,
       return obj->Pointer;
    }
 
-   /* Flush any existing batchbuffer that might have written to this
-    * buffer.
-    */
-   intelFlush(ctx);
+   /* Flush any existing batchbuffer that might reference this data. */
+   if (drm_intel_bo_references(intel->batch->buf, intel_obj->buffer))
+      intelFlush(ctx);
 
    if (intel_obj->region)
       intel_bufferobj_cow(intel, intel_obj);
@@ -330,7 +330,8 @@ intel_bufferobj_map_range(GLcontext * ctx,
     * the batchbuffer so that GEM knows about the buffer access for later
     * syncing.
     */
-   if (!(access & GL_MAP_UNSYNCHRONIZED_BIT))
+   if (!(access & GL_MAP_UNSYNCHRONIZED_BIT) &&
+       drm_intel_bo_references(intel->batch->buf, intel_obj->buffer))
       intelFlush(ctx);
 
    if (intel_obj->buffer == NULL) {
index 66201b1f465f82bf7d284b1c24fb6d8d3e056ec3..5c915178e756b538044f88f414a88e9bcb105a0e 100644 (file)
@@ -201,6 +201,9 @@ try_pbo_upload(struct intel_context *intel,
    struct intel_buffer_object *pbo = intel_buffer_object(unpack->BufferObj);
    GLuint src_offset, src_stride;
    GLuint dst_offset, dst_stride;
+   dri_bo *dst_buffer = intel_region_buffer(intel,
+                                           intelImage->mt->region,
+                                           INTEL_WRITE_FULL);
 
    if (!_mesa_is_bufferobj(unpack->BufferObj) ||
        intel->ctx._ImageTransferState ||
@@ -223,7 +226,8 @@ try_pbo_upload(struct intel_context *intel,
 
    dst_stride = intelImage->mt->pitch;
 
-   intelFlush(&intel->ctx);
+   if (drm_intel_bo_references(intel->batch->buf, dst_buffer))
+      intelFlush(&intel->ctx);
    LOCK_HARDWARE(intel);
    {
       dri_bo *src_buffer = intel_bufferobj_buffer(intel, pbo, INTEL_READ);
@@ -316,8 +320,6 @@ intelTexImage(GLcontext * ctx,
    DBG("%s target %s level %d %dx%dx%d border %d\n", __FUNCTION__,
        _mesa_lookup_enum_by_nr(target), level, width, height, depth, border);
 
-   intelFlush(ctx);
-
    intelImage->face = target_to_face(target);
    intelImage->level = level;
 
@@ -478,13 +480,20 @@ intelTexImage(GLcontext * ctx,
    LOCK_HARDWARE(intel);
 
    if (intelImage->mt) {
-      if (pixels != NULL)
+      if (pixels != NULL) {
+        /* Flush any queued rendering with the texture before mapping. */
+        if (drm_intel_bo_references(intel->batch->buf,
+                                    intelImage->mt->region->buffer)) {
+           intelFlush(ctx);
+        }
          texImage->Data = intel_miptree_image_map(intel,
                                                   intelImage->mt,
                                                   intelImage->face,
                                                   intelImage->level,
                                                   &dstRowStride,
                                                   intelImage->base.ImageOffsets);
+      }
+
       texImage->RowStride = dstRowStride / intelImage->mt->cpp;
    }
    else {