summaryrefslogtreecommitdiff
path: root/src/mesa/drivers/dri/i965/intel_batchbuffer.c
diff options
context:
space:
mode:
authorKeith Whitwell <keith@tungstengraphics.com>2006-09-07 19:05:40 +0000
committerKeith Whitwell <keith@tungstengraphics.com>2006-09-07 19:05:40 +0000
commit493b2ddecb47fdacc4b73d9c9a3ba2e46489105f (patch)
tree011c2f4570d336020c0db6562d294d638a981531 /src/mesa/drivers/dri/i965/intel_batchbuffer.c
parentc26f36c830cc6df1093a145eb43645f535004eb7 (diff)
Cope with memory pool fragmentation by allowing a second attempt at
rendering operations to take place after evicting all resident buffers. Cope better with memory allocation failures throughout the driver and improve tracking of failures.
Diffstat (limited to 'src/mesa/drivers/dri/i965/intel_batchbuffer.c')
-rw-r--r--src/mesa/drivers/dri/i965/intel_batchbuffer.c23
1 files changed, 17 insertions, 6 deletions
diff --git a/src/mesa/drivers/dri/i965/intel_batchbuffer.c b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
index 7510ac5b92..636f363095 100644
--- a/src/mesa/drivers/dri/i965/intel_batchbuffer.c
+++ b/src/mesa/drivers/dri/i965/intel_batchbuffer.c
@@ -62,14 +62,15 @@ static void intel_batchbuffer_reset_cb( struct intel_context *intel,
batch->ptr = NULL;
}
-void intel_batchbuffer_map( struct intel_batchbuffer *batch )
+GLubyte *intel_batchbuffer_map( struct intel_batchbuffer *batch )
{
if (!batch->map) {
batch->map = bmMapBuffer(batch->intel, batch->buffer,
BM_MEM_AGP|BM_MEM_LOCAL|BM_CLIENT|BM_WRITE);
batch->ptr += (unsigned long)batch->map;
}
- assert(batch->map);
+
+ return batch->map;
}
void intel_batchbuffer_unmap( struct intel_batchbuffer *batch )
@@ -122,18 +123,19 @@ void intel_batchbuffer_free( struct intel_batchbuffer *batch )
#define MI_BATCH_BUFFER_END (0xA<<23)
-void intel_batchbuffer_flush( struct intel_batchbuffer *batch )
+GLboolean intel_batchbuffer_flush( struct intel_batchbuffer *batch )
{
struct intel_context *intel = batch->intel;
GLuint used = batch->ptr - (batch->map + batch->offset);
GLuint offset;
GLboolean ignore_cliprects = (batch->flags & INTEL_BATCH_CLIPRECTS) ? GL_FALSE : GL_TRUE;
+ GLint retval = GL_TRUE;
assert(intel->locked);
if (used == 0) {
bmReleaseBuffers( batch->intel );
- return;
+ return GL_TRUE;
}
/* Throw away non-effective packets.
@@ -148,7 +150,7 @@ void intel_batchbuffer_flush( struct intel_batchbuffer *batch )
sched_yield();
LOCK_HARDWARE(intel);
- return;
+ return GL_TRUE;
}
@@ -177,7 +179,10 @@ void intel_batchbuffer_flush( struct intel_batchbuffer *batch )
offset = bmBufferOffset(batch->intel, batch->buffer);
if (!bmValidateBuffers( batch->intel )) {
- assert(0);
+ assert(intel->locked);
+ bmReleaseBuffers( batch->intel );
+ retval = GL_FALSE;
+ goto out;
}
@@ -208,8 +213,14 @@ void intel_batchbuffer_flush( struct intel_batchbuffer *batch )
/* Reset the buffer:
*/
+ out:
intel_batchbuffer_reset( batch );
intel_batchbuffer_map( batch );
+
+ if (!retval)
+ DBG("%s failed\n", __FUNCTION__);
+
+ return retval;
}