summaryrefslogtreecommitdiff
path: root/src/gallium/drivers/i965/brw_clip_state.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_clip_state.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_clip_state.c')
-rw-r--r--src/gallium/drivers/i965/brw_clip_state.c60
1 files changed, 36 insertions, 24 deletions
diff --git a/src/gallium/drivers/i965/brw_clip_state.c b/src/gallium/drivers/i965/brw_clip_state.c
index 6f8309fea9..d4e3c43c61 100644
--- a/src/gallium/drivers/i965/brw_clip_state.c
+++ b/src/gallium/drivers/i965/brw_clip_state.c
@@ -72,12 +72,13 @@ clip_unit_populate_key(struct brw_context *brw, struct brw_clip_unit_key *key)
key->depth_clamp = 0; // XXX: add this to gallium: ctx->Transform.DepthClamp;
}
-static struct brw_winsys_buffer *
+static enum pipe_error
clip_unit_create_from_key(struct brw_context *brw,
- struct brw_clip_unit_key *key)
+ struct brw_clip_unit_key *key,
+ struct brw_winsys_buffer **bo_out)
{
struct brw_clip_unit_state clip;
- struct brw_winsys_buffer *bo;
+ enum pipe_error ret;
memset(&clip, 0, sizeof(clip));
@@ -141,39 +142,50 @@ clip_unit_create_from_key(struct brw_context *brw,
clip.viewport_ymin = -1;
clip.viewport_ymax = 1;
- bo = brw_upload_cache(&brw->cache, BRW_CLIP_UNIT,
- key, sizeof(*key),
- &brw->clip.prog_bo, 1,
- &clip, sizeof(clip),
- NULL, NULL);
+ ret = brw_upload_cache(&brw->cache, BRW_CLIP_UNIT,
+ key, sizeof(*key),
+ &brw->clip.prog_bo, 1,
+ &clip, sizeof(clip),
+ NULL, NULL,
+ bo_out);
+ if (ret)
+ return ret;
/* Emit clip program relocation */
assert(brw->clip.prog_bo);
- brw->sws->bo_emit_reloc(bo,
- BRW_USAGE_STATE,
- clip.thread0.grf_reg_count << 1,
- offsetof(struct brw_clip_unit_state, thread0),
- brw->clip.prog_bo);
-
- return bo;
+ ret = brw->sws->bo_emit_reloc(*bo_out,
+ BRW_USAGE_STATE,
+ clip.thread0.grf_reg_count << 1,
+ offsetof(struct brw_clip_unit_state, thread0),
+ brw->clip.prog_bo);
+ if (ret)
+ return ret;
+
+ return PIPE_OK;
}
static int upload_clip_unit( struct brw_context *brw )
{
struct brw_clip_unit_key key;
+ enum pipe_error ret;
clip_unit_populate_key(brw, &key);
- brw->sws->bo_unreference(brw->clip.state_bo);
- brw->clip.state_bo = brw_search_cache(&brw->cache, BRW_CLIP_UNIT,
- &key, sizeof(key),
- &brw->clip.prog_bo, 1,
- NULL);
- if (brw->clip.state_bo == NULL) {
- brw->clip.state_bo = clip_unit_create_from_key(brw, &key);
- }
+ if (brw_search_cache(&brw->cache, BRW_CLIP_UNIT,
+ &key, sizeof(key),
+ &brw->clip.prog_bo, 1,
+ NULL,
+ &brw->clip.state_bo))
+ return PIPE_OK;
+
+ /* Create new:
+ */
+ ret = clip_unit_create_from_key(brw, &key,
+ &brw->clip.state_bo);
+ if (ret)
+ return ret;
- return 0;
+ return PIPE_OK;
}
const struct brw_tracked_state brw_clip_unit = {