summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJosé Fonseca <jrfonseca@tungstengraphics.com>2007-11-03 01:31:47 +0000
committerJosé Fonseca <jrfonseca@tungstengraphics.com>2007-11-03 02:01:32 +0000
commit5fa6ea68586e906a984291dd4c20f664924157eb (patch)
tree1d0f22c5e99e7891447847109249cc5c611e73af
parent5c1606a2b3e951c32f028e0b328e6c06e9424e28 (diff)
Do something sensible when failed to reserve space in the batch buffer.
-rw-r--r--src/mesa/pipe/i915simple/i915_blit.c10
-rw-r--r--src/mesa/pipe/i915simple/i915_flush.c5
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_emit.c7
-rw-r--r--src/mesa/pipe/i915simple/i915_prim_vbuf.c11
-rw-r--r--src/mesa/pipe/i915simple/i915_state_emit.c2
5 files changed, 17 insertions, 18 deletions
diff --git a/src/mesa/pipe/i915simple/i915_blit.c b/src/mesa/pipe/i915simple/i915_blit.c
index 0a8a1542d7..a1f953ebbe 100644
--- a/src/mesa/pipe/i915simple/i915_blit.c
+++ b/src/mesa/pipe/i915simple/i915_blit.c
@@ -69,7 +69,10 @@ i915_fill_blit(struct i915_context *i915,
// __FUNCTION__, dst_buffer, dst_pitch, dst_offset, x, y, w, h);
- BEGIN_BATCH(6, 1);
+ if (!BEGIN_BATCH(6, 1)) {
+ FLUSH_BATCH();
+ assert(BEGIN_BATCH(6, 1));
+ }
OUT_BATCH(CMD);
OUT_BATCH(BR13);
OUT_BATCH((y << 16) | x);
@@ -140,7 +143,10 @@ i915_copy_blit( struct i915_context *i915,
assert (dst_pitch > 0 && src_pitch > 0);
- BEGIN_BATCH(8, 2);
+ if (!BEGIN_BATCH(8, 2)) {
+ FLUSH_BATCH();
+ assert(BEGIN_BATCH(8, 2));
+ }
OUT_BATCH(CMD);
OUT_BATCH(BR13);
OUT_BATCH((dst_y << 16) | dst_x);
diff --git a/src/mesa/pipe/i915simple/i915_flush.c b/src/mesa/pipe/i915simple/i915_flush.c
index 9a31342cbd..9c2adf8763 100644
--- a/src/mesa/pipe/i915simple/i915_flush.c
+++ b/src/mesa/pipe/i915simple/i915_flush.c
@@ -56,7 +56,10 @@ static void i915_flush( struct pipe_context *pipe,
if (flags & PIPE_FLUSH_TEXTURE_CACHE)
flush |= FLUSH_MAP_CACHE;
- BEGIN_BATCH( 1, 0 );
+ if (!BEGIN_BATCH(1, 0)) {
+ FLUSH_BATCH();
+ assert(BEGIN_BATCH(1, 0));
+ }
OUT_BATCH( flush );
ADVANCE_BATCH();
}
diff --git a/src/mesa/pipe/i915simple/i915_prim_emit.c b/src/mesa/pipe/i915simple/i915_prim_emit.c
index 40e33e6e09..0a8be79ae4 100644
--- a/src/mesa/pipe/i915simple/i915_prim_emit.c
+++ b/src/mesa/pipe/i915simple/i915_prim_emit.c
@@ -123,7 +123,6 @@ emit_prim( struct draw_stage *stage,
{
struct i915_context *i915 = setup_stage(stage)->i915;
unsigned vertex_size = i915->current.vertex_info.size * 4; /* in bytes */
- unsigned *ptr;
unsigned i;
assert(vertex_size >= 12); /* never smaller than 12 bytes */
@@ -134,8 +133,7 @@ emit_prim( struct draw_stage *stage,
if (i915->hardware_dirty)
i915_emit_hardware_state( i915 );
- ptr = BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 );
- if (ptr == 0) {
+ if (!BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 )) {
FLUSH_BATCH();
/* Make sure state is re-emitted after a flush:
@@ -143,8 +141,7 @@ emit_prim( struct draw_stage *stage,
i915_update_derived( i915 );
i915_emit_hardware_state( i915 );
- ptr = BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 );
- if (ptr == 0) {
+ if (!BEGIN_BATCH( 1 + nr * vertex_size / 4, 0 )) {
assert(0);
return;
}
diff --git a/src/mesa/pipe/i915simple/i915_prim_vbuf.c b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
index 6f497879ad..3632adce79 100644
--- a/src/mesa/pipe/i915simple/i915_prim_vbuf.c
+++ b/src/mesa/pipe/i915simple/i915_prim_vbuf.c
@@ -303,12 +303,7 @@ static void vbuf_draw( struct draw_stage *stage )
if (i915->hardware_dirty)
i915_emit_hardware_state( i915 );
- ptr = BEGIN_BATCH( 4 + (nr + 1)/2, 1 );
-#if 1
- assert(ptr);
-#else
- /* XXX: below is bogus as ptr always nonzero except in fatal errors */
- if (ptr == 0) {
+ if (!BEGIN_BATCH( 4 + (nr + 1)/2, 1 )) {
FLUSH_BATCH();
/* Make sure state is re-emitted after a flush:
@@ -316,13 +311,11 @@ static void vbuf_draw( struct draw_stage *stage )
i915_update_derived( i915 );
i915_emit_hardware_state( i915 );
- ptr = BEGIN_BATCH( 2, 1 );
- if (ptr == 0) {
+ if (!BEGIN_BATCH( 4 + (nr + 1)/2, 1 )) {
assert(0);
return;
}
}
-#endif
/* FIXME: don't do this every time */
OUT_BATCH( _3DSTATE_LOAD_STATE_IMMEDIATE_1 |
diff --git a/src/mesa/pipe/i915simple/i915_state_emit.c b/src/mesa/pipe/i915simple/i915_state_emit.c
index 15eff97813..29fe9d9718 100644
--- a/src/mesa/pipe/i915simple/i915_state_emit.c
+++ b/src/mesa/pipe/i915simple/i915_state_emit.c
@@ -81,7 +81,7 @@ i915_emit_hardware_state(struct i915_context *i915 )
if(!BEGIN_BATCH(dwords, relocs)) {
FLUSH_BATCH();
- BEGIN_BATCH(dwords, relocs);
+ assert(BEGIN_BATCH(dwords, relocs));
}
/* 14 dwords, 0 relocs */