summaryrefslogtreecommitdiff
path: root/src/drm
diff options
context:
space:
mode:
authorChris Wilson <chris@chris-wilson.co.uk>2010-02-02 17:38:06 +0000
committerChris Wilson <chris@chris-wilson.co.uk>2010-02-03 09:13:20 +0000
commit1315323b20398c7c4efa68e4e1c7f6fd6c1d8d91 (patch)
tree2f87eb2e91e0ccf77fd0011e3d2c9687fbeb8fd9 /src/drm
parente2be50c722347734801468d7d9568a18dbbaaa17 (diff)
drm/i915: check for batch buffer overflow.
Oops, the check for sufficient batch space mysteriously disappeared during the rearrangement.
Diffstat (limited to 'src/drm')
-rw-r--r--src/drm/cairo-drm-i915-private.h3
-rw-r--r--src/drm/cairo-drm-i915-shader.c44
-rw-r--r--src/drm/cairo-drm-i915-surface.c35
3 files changed, 44 insertions, 38 deletions
diff --git a/src/drm/cairo-drm-i915-private.h b/src/drm/cairo-drm-i915-private.h
index 060c21c8..ecd72f2c 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 d22c1c5d..059a205f 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 7db1222c..d3c3940e 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)