diff options
author | Eric Anholt <[email protected]> | 2011-03-13 13:43:05 -0700 |
---|---|---|
committer | Eric Anholt <[email protected]> | 2011-03-24 11:31:36 -0700 |
commit | 2911fa0cca86f7acbc5423cab4dd328a412253cd (patch) | |
tree | 5f2e9f733c02be234901680c2f758e2bf5cebb8e | |
parent | 4a101f957714dea2bc956d516d34c5b56ecb2c64 (diff) |
i965/fs: Make compile failure more verbose with INTEL_DEBUG=wm.
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs.cpp | 39 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs.h | 5 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp | 10 |
3 files changed, 36 insertions, 18 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_fs.cpp b/src/mesa/drivers/dri/i965/brw_fs.cpp index cdc9926c81c..ecc4d482b60 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs.cpp @@ -177,6 +177,23 @@ type_size(const struct glsl_type *type) } } +void +fs_visitor::fail(const char *format, ...) +{ + if (!failed) { + failed = true; + + if (INTEL_DEBUG & DEBUG_WM) { + fprintf(stderr, "FS compile failed: "); + + va_list va; + va_start(va, format); + vfprintf(stderr, format, va); + va_end(va); + } + } +} + /** * Returns how many MRFs an FS opcode will write over. * @@ -391,8 +408,7 @@ fs_visitor::setup_builtin_uniform_values(ir_variable *ir) } if (!statevar->name) { - this->fail = true; - printf("Failed to find builtin uniform `%s'\n", ir->name); + fail("Failed to find builtin uniform `%s'\n", ir->name); return; } @@ -503,7 +519,7 @@ fs_visitor::emit_general_interpolation(ir_variable *ir) if (ir->type->is_array()) { array_elements = ir->type->length; if (array_elements == 0) { - this->fail = true; + fail("dereferenced array '%s' has length 0\n", ir->name); } type = ir->type->fields.array; } else { @@ -821,9 +837,8 @@ fs_visitor::visit(ir_expression *ir) ir->operands[operand]->accept(this); if (this->result.file == BAD_FILE) { ir_print_visitor v; - printf("Failed to get tree for expression operand:\n"); + fail("Failed to get tree for expression operand:\n"); ir->operands[operand]->accept(&v); - this->fail = true; } op[operand] = this->result; @@ -1634,7 +1649,7 @@ fs_visitor::emit_bool_to_cond_code(ir_rvalue *ir) default: assert(!"not reached"); - this->fail = true; + fail("bad cond code\n"); break; } return; @@ -1724,7 +1739,7 @@ fs_visitor::emit_if_gen6(ir_if *ir) assert(!"not reached"); inst = emit(BRW_OPCODE_IF, reg_null_d, op[0], fs_reg(0)); inst->conditional_mod = BRW_CONDITIONAL_NZ; - this->fail = true; + fail("bad condition\n"); return; } return; @@ -3631,7 +3646,7 @@ fs_visitor::generate_code() } else { _mesa_problem(ctx, "Unsupported opcode %d in FS", inst->opcode); } - this->fail = true; + fail("unsupported opcode in FS\n"); } if (unlikely(INTEL_DEBUG & DEBUG_WM)) { @@ -3762,18 +3777,18 @@ brw_wm_fs_emit(struct brw_context *brw, struct brw_wm_compile *c) v.assign_regs_trivial(); else { while (!v.assign_regs()) { - if (v.fail) + if (v.failed) break; } } } - if (!v.fail) + if (!v.failed) v.generate_code(); - assert(!v.fail); /* FINISHME: Cleanly fail, tested at link time, etc. */ + assert(!v.failed); /* FINISHME: Cleanly fail, tested at link time, etc. */ - if (v.fail) + if (v.failed) return GL_FALSE; c->prog_data.total_grf = v.grf_used; diff --git a/src/mesa/drivers/dri/i965/brw_fs.h b/src/mesa/drivers/dri/i965/brw_fs.h index 6551247559f..e48bf40e3e4 100644 --- a/src/mesa/drivers/dri/i965/brw_fs.h +++ b/src/mesa/drivers/dri/i965/brw_fs.h @@ -364,7 +364,7 @@ public: this->ctx = &intel->ctx; this->mem_ctx = ralloc_context(NULL); this->shader = shader; - this->fail = false; + this->failed = false; this->variable_ht = hash_table_ctor(0, hash_table_pointer_hash, hash_table_pointer_compare); @@ -476,6 +476,7 @@ public: bool remove_duplicate_mrf_writes(); bool virtual_grf_interferes(int a, int b); void schedule_instructions(); + void fail(const char *msg, ...); void generate_code(); void generate_fb_write(fs_inst *inst); @@ -549,7 +550,7 @@ public: ir_instruction *base_ir; /** @} */ - bool fail; + bool failed; /* Result of last visit() method. */ fs_reg result; diff --git a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp index f0277423170..479a91436a7 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_reg_allocate.cpp @@ -119,8 +119,7 @@ fs_visitor::assign_regs() } if (i == class_count) { if (this->virtual_grf_sizes[r] >= base_reg_count) { - fprintf(stderr, "Object too large to register allocate.\n"); - this->fail = true; + fail("Object too large to register allocate.\n"); } class_sizes[class_count++] = this->virtual_grf_sizes[r]; @@ -226,8 +225,11 @@ fs_visitor::assign_regs() * loop back into here to try again. */ int reg = choose_spill_reg(g); - if (reg == -1 || intel->gen >= 6) { - this->fail = true; + + if (reg == -1) { + fail("no register to spill\n"); + } else if (intel->gen >= 6) { + fail("no spilling support on gen6 yet\n"); } else { spill_reg(reg); } |