summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBrian Paul <brianp@vmware.com>2009-03-06 16:00:25 -0700
committerIan Romanick <ian.d.romanick@intel.com>2009-03-10 21:56:31 -0700
commit20d265a403c471ef68c5e1ba06e5d8382d5535d2 (patch)
tree7598393ce950eb1649e6eec9b81a71676e5119b3
parentc8f9bd0a7aceece56f5ce49495e982db2014176b (diff)
downloadmesa_7_4_idr_staging.tar.gz
i965: check if we run out of GRF/temp registersmesa_7_4_idr_staging
Before this change we would up emitting instructions with invalid register numbers. This typically (but not always) hung the GPU. For now, just prevent emitting bad instructions to avoid hangs. Still need to do some kind of proper error recovery. (cherry picked from commit e60b3067d81319236d63ad497e70658fd2e14eb3)
-rw-r--r--src/mesa/drivers/dri/i965/brw_wm_glsl.c28
1 files changed, 26 insertions, 2 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_wm_glsl.c b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
index 963b7e9cc86..11f592d1b88 100644
--- a/src/mesa/drivers/dri/i965/brw_wm_glsl.c
+++ b/src/mesa/drivers/dri/i965/brw_wm_glsl.c
@@ -89,8 +89,14 @@ get_reg(struct brw_wm_compile *c, int file, int index, int component, int nr, GL
break;
case PROGRAM_UNDEFINED:
return brw_null_reg();
- default:
+ case PROGRAM_TEMPORARY:
+ case PROGRAM_INPUT:
+ case PROGRAM_OUTPUT:
+ case PROGRAM_PAYLOAD:
break;
+ default:
+ _mesa_problem(NULL, "Unexpected file in get_reg()");
+ return brw_null_reg();
}
if(c->wm_regs[file][index][component].inited)
@@ -103,7 +109,20 @@ get_reg(struct brw_wm_compile *c, int file, int index, int component, int nr, GL
c->reg_index++;
}
- if (neg & (1<< component)) {
+ if (c->reg_index >= BRW_WM_MAX_GRF - 12) {
+ /* ran out of temporary registers! */
+#if 1
+ /* This is a big hack for now.
+ * Return bad register index, but don't just crash hange the GPU.
+ */
+ _mesa_fprintf(stderr, "out of regs %d\n", c->reg_index);
+ c->reg_index = BRW_WM_MAX_GRF - 13;
+#else
+ return brw_null_reg();
+#endif
+ }
+
+ if (neg & (1 << component)) {
reg = negate(reg);
}
if (abs)
@@ -2515,6 +2534,11 @@ static void brw_wm_emit_glsl(struct brw_context *brw, struct brw_wm_compile *c)
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
}
post_wm_emit(c);
+
+ if (c->reg_index >= BRW_WM_MAX_GRF) {
+ _mesa_problem(NULL, "Ran out of registers in brw_wm_emit_glsl()");
+ /* XXX we need to do some proper error recovery here */
+ }
}
void brw_wm_glsl_emit(struct brw_context *brw, struct brw_wm_compile *c)