summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/i965/brw_batchbuffer.c
diff options
context:
space:
mode:
authorKeith Whitwell <keithw@vmware.com>2009-11-05 13:57:05 +0000
committerKeith Whitwell <keithw@vmware.com>2009-11-05 14:01:37 +0000
commitc796aed5ddad011d66e631c4cafdbf779e73f213 (patch)
treed8a510233b281c9d6a0690632948f10a03819a84 /src/gallium/drivers/i965/brw_batchbuffer.c
parent31b8b1dd36d9f07a7893a89ee985d83c4d0bb95b (diff)
i965g: add lots of error checks and early returns
Any allocation that may fail should be checked, and propogate the error upwards. At the highest level we will flush batch and retry. This is an alternate strategy to what the original DRI driver did of attempting to flush batch from the lowest levels (eg inside BEGIN_BATCH). The trouble with that strategy was that flushes could occur at unexpected times, and additionally there was a need for a wierd notification mechanism to propogate the 'lost context' state back up to higher levels. Propogating the errors directly gives us a lot of flexibility how to deal with these states, at the expense of a lot more checking in the code. Will add some sanity checks later to make sure that out-of-memory conditions are properly escalated and not lost halfway up the stack.
Diffstat (limited to 'src/gallium/drivers/i965/brw_batchbuffer.c')
-rw-r--r--src/gallium/drivers/i965/brw_batchbuffer.c19
1 files changed, 10 insertions, 9 deletions
diff --git a/src/gallium/drivers/i965/brw_batchbuffer.c b/src/gallium/drivers/i965/brw_batchbuffer.c
index ca612e5ed0..e5f73bd6a3 100644
--- a/src/gallium/drivers/i965/brw_batchbuffer.c
+++ b/src/gallium/drivers/i965/brw_batchbuffer.c
@@ -38,17 +38,17 @@
#define USE_MALLOC_BUFFER 1
#define ALWAYS_EMIT_MI_FLUSH 1
-void
+enum pipe_error
brw_batchbuffer_reset(struct brw_batchbuffer *batch)
{
- if (batch->buf) {
- batch->sws->bo_unreference(batch->buf);
- batch->buf = NULL;
- }
+ enum pipe_error ret;
- batch->buf = batch->sws->bo_alloc(batch->sws,
- BRW_BUFFER_TYPE_BATCH,
- BRW_BATCH_SIZE, 4096);
+ ret = batch->sws->bo_alloc( batch->sws,
+ BRW_BUFFER_TYPE_BATCH,
+ BRW_BATCH_SIZE, 4096,
+ &batch->buf );
+ if (ret)
+ return ret;
if (batch->malloc_buffer)
batch->map = batch->malloc_buffer;
@@ -59,6 +59,7 @@ brw_batchbuffer_reset(struct brw_batchbuffer *batch)
batch->size = BRW_BATCH_SIZE;
batch->ptr = batch->map;
+ return PIPE_OK;
}
struct brw_batchbuffer *
@@ -91,7 +92,7 @@ brw_batchbuffer_free(struct brw_batchbuffer *batch)
batch->map = NULL;
}
- batch->sws->bo_unreference(batch->buf);
+ bo_reference(&batch->buf, NULL);
FREE(batch);
}