[cairo-commit] 3 commits - src/drm

Chris Wilson ickle at kemper.freedesktop.org
Wed Feb 3 01:13:42 PST 2010


 src/drm/cairo-drm-i915-private.h |    5 ---
 src/drm/cairo-drm-i915-shader.c  |   50 +++++++++++++++++++++++++++++++++++++++
 src/drm/cairo-drm-i915-surface.c |   35 ---------------------------
 3 files changed, 51 insertions(+), 39 deletions(-)

New commits:
commit 597dd24ddcc763281c82790b7677e54dc2db8f92
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Wed Feb 3 08:53:44 2010 +0000

    drm/i915: Free potential leak of cloned textures.

diff --git a/src/drm/cairo-drm-i915-shader.c b/src/drm/cairo-drm-i915-shader.c
index 059a205..ab61947 100644
--- a/src/drm/cairo-drm-i915-shader.c
+++ b/src/drm/cairo-drm-i915-shader.c
@@ -1362,6 +1362,7 @@ i915_shader_acquire_surface (i915_shader_t *shader,
     cairo_filter_t filter;
     cairo_matrix_t m;
     int src_x = 0, src_y = 0;
+    cairo_surface_t *free_me = NULL;
     cairo_status_t status;
 
     assert (src->type.fragment == (i915_fragment_shader_t) -1);
@@ -1501,6 +1502,8 @@ i915_shader_acquire_surface (i915_shader_t *shader,
 	    _cairo_surface_release_source_image (surface, image, image_extra);
 	    if (unlikely (status))
 		return status;
+
+	    free_me = &s->intel.drm.base;
 	}
 
 	src->type.fragment = FS_TEXTURE;
@@ -1558,6 +1561,9 @@ i915_shader_acquire_surface (i915_shader_t *shader,
     cairo_matrix_init_scale (&m, 1. / surface_width, 1. / surface_height);
     cairo_matrix_multiply (&src->base.matrix, &src->base.matrix, &m);
 
+    if (free_me != NULL)
+	cairo_surface_destroy (free_me);
+
     return CAIRO_STATUS_SUCCESS;
 }
 
commit 913a31494ec4bd000dfa303e362d8273b6857cfe
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 2 17:49:09 2010 +0000

    drm/i915: Increase batch buffer space.

diff --git a/src/drm/cairo-drm-i915-private.h b/src/drm/cairo-drm-i915-private.h
index ecd72f2..6ef1474 100644
--- a/src/drm/cairo-drm-i915-private.h
+++ b/src/drm/cairo-drm-i915-private.h
@@ -625,7 +625,7 @@ typedef struct i915_image_private {
     intel_buffer_cache_t *container;
 } i915_image_private_t;
 
-#define I915_BATCH_SIZE (64*1024)
+#define I915_BATCH_SIZE (128*1024)
 #define I915_VBO_SIZE (512*1024)
 #define I915_MAX_RELOCS 2048
 
commit 1315323b20398c7c4efa68e4e1c7f6fd6c1d8d91
Author: Chris Wilson <chris at chris-wilson.co.uk>
Date:   Tue Feb 2 17:38:06 2010 +0000

    drm/i915: check for batch buffer overflow.
    
    Oops, the check for sufficient batch space mysteriously disappeared
    during the rearrangement.

diff --git a/src/drm/cairo-drm-i915-private.h b/src/drm/cairo-drm-i915-private.h
index 060c21c..ecd72f2 100644
--- a/src/drm/cairo-drm-i915-private.h
+++ b/src/drm/cairo-drm-i915-private.h
@@ -1096,9 +1096,6 @@ i915_batch_emit_reloc (i915_device_t *device,
     i915_batch_emit_dword (device, bo->offset + offset);
 }
 
-cairo_private cairo_status_t
-i915_vbo_flush (i915_device_t *device);
-
 cairo_private void
 i915_vbo_finish (i915_device_t *device);
 
diff --git a/src/drm/cairo-drm-i915-shader.c b/src/drm/cairo-drm-i915-shader.c
index d22c1c5..059a205 100644
--- a/src/drm/cairo-drm-i915-shader.c
+++ b/src/drm/cairo-drm-i915-shader.c
@@ -2627,6 +2627,35 @@ i915_shader_add_rectangle_general (const i915_shader_t *shader,
     /* XXX overflow! */
 }
 
+static cairo_status_t
+i915_vbo_flush (i915_device_t *device)
+{
+    assert (device->vertex_count);
+
+    if (device->vbo == 0) {
+	assert (device->floats_per_vertex);
+
+	OUT_DWORD (_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
+		   I1_LOAD_S (0) |
+		   I1_LOAD_S (1) |
+		   1);
+	device->vbo = device->batch.used++;
+	device->vbo_max_index = device->batch.used;
+	OUT_DWORD ((device->floats_per_vertex << S1_VERTEX_WIDTH_SHIFT) |
+		   (device->floats_per_vertex << S1_VERTEX_PITCH_SHIFT));
+    }
+
+    OUT_DWORD (PRIM3D_RECTLIST |
+	       PRIM3D_INDIRECT_SEQUENTIAL |
+	       device->vertex_count);
+    OUT_DWORD (device->vertex_index);
+
+    device->vertex_index += device->vertex_count;
+    device->vertex_count = 0;
+
+    return CAIRO_STATUS_SUCCESS;
+}
+
 cairo_status_t
 i915_shader_commit (i915_shader_t *shader,
 		    i915_device_t *device)
@@ -2639,6 +2668,12 @@ i915_shader_commit (i915_shader_t *shader,
     i915_shader_setup_dst (shader);
 
     if (i915_shader_needs_update (shader, device)) {
+	if (i915_batch_space (device) < 256) {
+	    status = i915_batch_flush (device);
+	    if (unlikely (status))
+		return status;
+	}
+
 	if (device->vertex_count) {
 	    status = i915_vbo_flush (device);
 	    if (unlikely (status))
@@ -2649,6 +2684,7 @@ i915_shader_commit (i915_shader_t *shader,
 	if (unlikely (status))
 	    return status;
 
+  update_shader:
 	i915_set_shader_target (device, shader);
 	i915_set_shader_mode (device, shader);
 	i915_set_shader_samplers (device, shader);
@@ -2663,6 +2699,14 @@ i915_shader_commit (i915_shader_t *shader,
     if (device->floats_per_vertex == floats_per_vertex)
 	return CAIRO_STATUS_SUCCESS;
 
+    if (i915_batch_space (device) < 8) {
+	status = i915_batch_flush (device);
+	if (unlikely (status))
+	    return status;
+
+	goto update_shader;
+    }
+
     if (device->vertex_count) {
 	status = i915_vbo_flush (device);
 	if (unlikely (status))
diff --git a/src/drm/cairo-drm-i915-surface.c b/src/drm/cairo-drm-i915-surface.c
index 7db1222..d3c3940 100644
--- a/src/drm/cairo-drm-i915-surface.c
+++ b/src/drm/cairo-drm-i915-surface.c
@@ -514,41 +514,6 @@ BAIL:
     return status;
 }
 
-cairo_status_t
-i915_vbo_flush (i915_device_t *device)
-{
-    assert (device->vertex_count);
-
-    if (device->vbo == 0) {
-	assert (device->floats_per_vertex);
-
-	if (i915_batch_space (device) < 9 ||
-	    ! i915_check_aperture_size (device, 1, I915_VBO_SIZE))
-	{
-	    return i915_batch_flush (device);
-	}
-
-	OUT_DWORD (_3DSTATE_LOAD_STATE_IMMEDIATE_1 |
-		   I1_LOAD_S (0) |
-		   I1_LOAD_S (1) |
-		   1);
-	device->vbo = device->batch.used++;
-	device->vbo_max_index = device->batch.used;
-	OUT_DWORD ((device->floats_per_vertex << S1_VERTEX_WIDTH_SHIFT) |
-		   (device->floats_per_vertex << S1_VERTEX_PITCH_SHIFT));
-    }
-
-    OUT_DWORD (PRIM3D_RECTLIST |
-	       PRIM3D_INDIRECT_SEQUENTIAL |
-	       device->vertex_count);
-    OUT_DWORD (device->vertex_index);
-
-    device->vertex_index += device->vertex_count;
-    device->vertex_count = 0;
-
-    return CAIRO_STATUS_SUCCESS;
-}
-
 #if 0
 static float *
 i915_add_rectangles (i915_device_t *device, int num_rects, int *count)


More information about the cairo-commit mailing list