Do something sensible when failed to reserve space in the batch buffer.
authorJosé Fonseca <jrfonseca@tungstengraphics.com>
Sat, 3 Nov 2007 01:31:47 +0000 (01:31 +0000)
committerJosé Fonseca <jrfonseca@tungstengraphics.com>
Sat, 3 Nov 2007 02:01:32 +0000 (02:01 +0000)
src/mesa/pipe/i915simple/i915_blit.c
src/mesa/pipe/i915simple/i915_flush.c
src/mesa/pipe/i915simple/i915_prim_emit.c
src/mesa/pipe/i915simple/i915_prim_vbuf.c
src/mesa/pipe/i915simple/i915_state_emit.c

index 0a8a154..a1f953e 100644 (file)
@@ -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);
index 9a31342..9c2adf8 100644 (file)
@@ -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();
    }
index 40e33e6..0a8be79 100644 (file)
@@ -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;
       }
index 6f49787..3632adc 100644 (file)
@@ -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 | 
index 15eff97..29fe9d9 100644 (file)
@@ -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 */