{
void *node;
- node = talloc_size(ctx, size);
+ node = talloc_zero_size(ctx, size);
assert(node != NULL);
return node;
bool saturate;
bool predicated;
int conditional_mod; /**< BRW_CONDITIONAL_* */
+
+ /** @{
+ * Annotation for the generated IR. One of the two can be set.
+ */
+ ir_instruction *ir;
+ const char *annotation;
+ /** @} */
};
class fs_visitor : public ir_visitor
this->frag_data = NULL;
this->frag_depth = NULL;
this->first_non_payload_grf = 0;
+
+ this->current_annotation = NULL;
+ this->annotation_string = NULL;
+ this->annotation_ir = NULL;
}
~fs_visitor()
{
ir_variable *frag_color, *frag_data, *frag_depth;
int first_non_payload_grf;
+ /** @{ debug annotation info */
+ const char *current_annotation;
+ ir_instruction *base_ir;
+ const char **annotation_string;
+ ir_instruction **annotation_ir;
+ /** @} */
+
bool fail;
/* Result of last visit() method. */
foreach_iter(exec_list_iterator, iter, sig->body) {
ir_instruction *ir = (ir_instruction *)iter.get();
+ this->base_ir = ir;
ir->accept(this);
}
fs_inst *list_inst = new(mem_ctx) fs_inst;
*list_inst = inst;
+ list_inst->annotation = this->current_annotation;
+ list_inst->ir = this->base_ir;
+
this->instructions.push_tail(list_inst);
return list_inst;
*/
fs_reg src_reg = reg_undef;
- /* Compute the pixel centers. */
+ this->current_annotation = "compute pixel centers";
this->pixel_x = fs_reg(this, glsl_type::uint_type);
this->pixel_y = fs_reg(this, glsl_type::uint_type);
emit(fs_inst(BRW_OPCODE_ADD,
fs_reg(stride(suboffset(g1_uw, 5), 2, 4, 0)),
fs_reg(brw_imm_v(0x11001100))));
- /* Compute the offsets from vertex 0 to the pixel centers */
+ this->current_annotation = "compute pixel deltas from v0";
this->delta_x = fs_reg(this, glsl_type::float_type);
this->delta_y = fs_reg(this, glsl_type::float_type);
emit(fs_inst(BRW_OPCODE_ADD,
this->pixel_y,
fs_reg(brw_vec1_grf(1, 1))));
+ this->current_annotation = "compute pos.w and 1/pos.w";
/* Compute wpos. Unlike many other varying inputs, we usually need it
* to produce 1/w, and the varying variable wouldn't show up.
*/
if (var->location == 0)
continue;
+ this->current_annotation = talloc_asprintf(this->mem_ctx,
+ "interpolate %s "
+ "(FRAG_ATTRIB[%d])",
+ var->name,
+ var->location);
emit_pinterp(var->location);
}
+ this->current_annotation = NULL;
}
void
void
fs_visitor::emit_fb_writes()
{
+ this->current_annotation = "FB write";
+
assert(this->frag_color || !"FINISHME: MRT");
fs_reg color = *(variable_storage(this->frag_color));
emit(fs_inst(FS_OPCODE_FB_WRITE,
fs_reg(0),
fs_reg(0)));
+
+ this->current_annotation = NULL;
}
void
void
fs_visitor::generate_code()
{
+ unsigned int annotation_len = 0;
+ int last_native_inst = 0;
+
foreach_iter(exec_list_iterator, iter, this->instructions) {
fs_inst *inst = (fs_inst *)iter.get();
struct brw_reg src[3], dst;
default:
assert(!"not reached");
}
+
+ if (annotation_len < p->nr_insn) {
+ annotation_len *= 2;
+ if (annotation_len < 16)
+ annotation_len = 16;
+
+ this->annotation_string = talloc_realloc(this->mem_ctx,
+ annotation_string,
+ const char *,
+ annotation_len);
+ this->annotation_ir = talloc_realloc(this->mem_ctx,
+ annotation_ir,
+ ir_instruction *,
+ annotation_len);
+ }
+
+ for (unsigned int i = last_native_inst; i < p->nr_insn; i++) {
+ this->annotation_string[i] = inst->annotation;
+ this->annotation_ir[i] = inst->ir;
+ }
+ last_native_inst = p->nr_insn;
}
}
/* Generate FS IR for main(). (the visitor only descends into
* functions called "main").
*/
- visit_exec_list(shader->ir, &v);
+ foreach_iter(exec_list_iterator, iter, *shader->ir) {
+ ir_instruction *ir = (ir_instruction *)iter.get();
+ v.base_ir = ir;
+ ir->accept(&v);
+ }
if (v.fail)
return GL_FALSE;
v.generate_code();
if (INTEL_DEBUG & DEBUG_WM) {
+ const char *last_annotation_string = NULL;
+ ir_instruction *last_annotation_ir = NULL;
+
printf("Native code for fragment shader %d:\n", prog->Name);
- for (unsigned int i = 0; i < p->nr_insn; i++)
+ for (unsigned int i = 0; i < p->nr_insn; i++) {
+ if (last_annotation_ir != v.annotation_ir[i]) {
+ last_annotation_ir = v.annotation_ir[i];
+ if (last_annotation_ir) {
+ printf(" ");
+ last_annotation_ir->print();
+ printf("\n");
+ }
+ }
+ if (last_annotation_string != v.annotation_string[i]) {
+ last_annotation_string = v.annotation_string[i];
+ if (last_annotation_string)
+ printf(" %s\n", last_annotation_string);
+ }
brw_disasm(stdout, &p->store[i], intel->gen);
+ }
printf("\n");
}