diff options
Diffstat (limited to 'src/mesa')
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_eu.c | 1 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_eu.h | 10 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_eu_emit.c | 13 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_fs_emit.cpp | 23 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vec4_emit.cpp | 23 | ||||
-rw-r--r-- | src/mesa/drivers/dri/i965/brw_vs_emit.c | 13 |
6 files changed, 25 insertions, 58 deletions
diff --git a/src/mesa/drivers/dri/i965/brw_eu.c b/src/mesa/drivers/dri/i965/brw_eu.c index c0126ff9ffb..83aae3ba4de 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.c +++ b/src/mesa/drivers/dri/i965/brw_eu.c @@ -197,6 +197,7 @@ brw_init_compile(struct brw_context *brw, struct brw_compile *p, void *mem_ctx) p->loop_stack_depth = 0; p->loop_stack_array_size = 16; p->loop_stack = rzalloc_array(mem_ctx, int, p->loop_stack_array_size); + p->if_depth_in_loop = rzalloc_array(mem_ctx, int, p->loop_stack_array_size); } diff --git a/src/mesa/drivers/dri/i965/brw_eu.h b/src/mesa/drivers/dri/i965/brw_eu.h index 8d06fefb573..11e7161dc66 100644 --- a/src/mesa/drivers/dri/i965/brw_eu.h +++ b/src/mesa/drivers/dri/i965/brw_eu.h @@ -134,6 +134,12 @@ struct brw_compile { * encountered. */ int *loop_stack; + /** + * pre-gen6, the BREAK and CONT instructions had to tell how many IF/ENDIF + * blocks they were popping out of, to fix up the mask stack. This tracks + * the IF/ENDIF nesting in each current nested loop level. + */ + int *if_depth_in_loop; int loop_stack_depth; int loop_stack_array_size; @@ -1026,8 +1032,8 @@ struct brw_instruction *brw_DO(struct brw_compile *p, struct brw_instruction *brw_WHILE(struct brw_compile *p); -struct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count); -struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count); +struct brw_instruction *brw_BREAK(struct brw_compile *p); +struct brw_instruction *brw_CONT(struct brw_compile *p); struct brw_instruction *gen6_CONT(struct brw_compile *p); /* Forward jumps: */ diff --git a/src/mesa/drivers/dri/i965/brw_eu_emit.c b/src/mesa/drivers/dri/i965/brw_eu_emit.c index 30ae3bb2ac0..11f40807dbd 100644 --- a/src/mesa/drivers/dri/i965/brw_eu_emit.c +++ b/src/mesa/drivers/dri/i965/brw_eu_emit.c @@ -918,10 +918,13 @@ push_loop_stack(struct brw_compile *p, struct brw_instruction *inst) p->loop_stack_array_size *= 2; p->loop_stack = reralloc(p->mem_ctx, p->loop_stack, int, p->loop_stack_array_size); + p->if_depth_in_loop = reralloc(p->mem_ctx, p->if_depth_in_loop, int, + p->loop_stack_array_size); } p->loop_stack[p->loop_stack_depth] = inst - p->store; p->loop_stack_depth++; + p->if_depth_in_loop[p->loop_stack_depth] = 0; } static struct brw_instruction * @@ -980,6 +983,7 @@ brw_IF(struct brw_compile *p, GLuint execute_size) p->current->header.predicate_control = BRW_PREDICATE_NONE; push_if_stack(p, insn); + p->if_depth_in_loop[p->loop_stack_depth]++; return insn; } @@ -1187,6 +1191,7 @@ brw_ENDIF(struct brw_compile *p) struct brw_instruction *if_inst = NULL; /* Pop the IF and (optional) ELSE instructions from the stack */ + p->if_depth_in_loop[p->loop_stack_depth]--; p->if_stack_depth--; if (p->if_stack[p->if_stack_depth]->header.opcode == BRW_OPCODE_ELSE) { else_inst = p->if_stack[p->if_stack_depth]; @@ -1245,7 +1250,7 @@ brw_ENDIF(struct brw_compile *p) patch_IF_ELSE(p, if_inst, else_inst, insn); } -struct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count) +struct brw_instruction *brw_BREAK(struct brw_compile *p) { struct intel_context *intel = &p->brw->intel; struct brw_instruction *insn; @@ -1260,7 +1265,7 @@ struct brw_instruction *brw_BREAK(struct brw_compile *p, int pop_count) brw_set_src0(p, insn, brw_ip_reg()); brw_set_src1(p, insn, brw_imm_d(0x0)); insn->bits3.if_else.pad0 = 0; - insn->bits3.if_else.pop_count = pop_count; + insn->bits3.if_else.pop_count = p->if_depth_in_loop[p->loop_stack_depth]; } insn->header.compression_control = BRW_COMPRESSION_NONE; insn->header.execution_size = BRW_EXECUTE_8; @@ -1284,7 +1289,7 @@ struct brw_instruction *gen6_CONT(struct brw_compile *p) return insn; } -struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count) +struct brw_instruction *brw_CONT(struct brw_compile *p) { struct brw_instruction *insn; insn = next_insn(p, BRW_OPCODE_CONTINUE); @@ -1295,7 +1300,7 @@ struct brw_instruction *brw_CONT(struct brw_compile *p, int pop_count) insn->header.execution_size = BRW_EXECUTE_8; /* insn->header.mask_control = BRW_MASK_DISABLE; */ insn->bits3.if_else.pad0 = 0; - insn->bits3.if_else.pop_count = pop_count; + insn->bits3.if_else.pop_count = p->if_depth_in_loop[p->loop_stack_depth]; return insn; } diff --git a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp index 91e6961982f..b68d8cb8679 100644 --- a/src/mesa/drivers/dri/i965/brw_fs_emit.cpp +++ b/src/mesa/drivers/dri/i965/brw_fs_emit.cpp @@ -656,12 +656,6 @@ fs_visitor::generate_code() const char *last_annotation_string = NULL; ir_instruction *last_annotation_ir = NULL; - int loop_stack_array_size = 16; - int loop_stack_depth = 0; - int *if_depth_in_loop = - rzalloc_array(this->mem_ctx, int, loop_stack_array_size); - - if (unlikely(INTEL_DEBUG & DEBUG_WM)) { printf("Native code for fragment shader %d (%d-wide dispatch):\n", prog->Name, c->dispatch_width); @@ -781,7 +775,6 @@ fs_visitor::generate_code() } else { brw_IF(p, c->dispatch_width == 16 ? BRW_EXECUTE_16 : BRW_EXECUTE_8); } - if_depth_in_loop[loop_stack_depth]++; break; case BRW_OPCODE_ELSE: @@ -789,22 +782,14 @@ fs_visitor::generate_code() break; case BRW_OPCODE_ENDIF: brw_ENDIF(p); - if_depth_in_loop[loop_stack_depth]--; break; case BRW_OPCODE_DO: brw_DO(p, BRW_EXECUTE_8); - loop_stack_depth++; - if (loop_stack_array_size <= loop_stack_depth) { - loop_stack_array_size *= 2; - if_depth_in_loop = reralloc(this->mem_ctx, if_depth_in_loop, int, - loop_stack_array_size); - } - if_depth_in_loop[loop_stack_depth] = 0; break; case BRW_OPCODE_BREAK: - brw_BREAK(p, if_depth_in_loop[loop_stack_depth]); + brw_BREAK(p); brw_set_predicate_control(p, BRW_PREDICATE_NONE); break; case BRW_OPCODE_CONTINUE: @@ -812,13 +797,11 @@ fs_visitor::generate_code() if (intel->gen >= 6) gen6_CONT(p); else - brw_CONT(p, if_depth_in_loop[loop_stack_depth]); + brw_CONT(p); brw_set_predicate_control(p, BRW_PREDICATE_NONE); break; case BRW_OPCODE_WHILE: - assert(loop_stack_depth > 0); - loop_stack_depth--; brw_WHILE(p); break; @@ -923,8 +906,6 @@ fs_visitor::generate_code() printf("\n"); } - ralloc_free(if_depth_in_loop); - brw_set_uip_jip(p); /* OK, while the INTEL_DEBUG=wm above is very nice for debugging FS diff --git a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp index 8ea5c14075c..a618614c73c 100644 --- a/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp +++ b/src/mesa/drivers/dri/i965/brw_vec4_emit.cpp @@ -798,12 +798,6 @@ vec4_visitor::generate_code() const char *last_annotation_string = NULL; ir_instruction *last_annotation_ir = NULL; - int loop_stack_array_size = 16; - int loop_stack_depth = 0; - int *if_depth_in_loop = - rzalloc_array(this->mem_ctx, int, loop_stack_array_size); - - if (unlikely(INTEL_DEBUG & DEBUG_VS)) { printf("Native code for vertex shader %d:\n", prog->Name); } @@ -917,7 +911,6 @@ vec4_visitor::generate_code() struct brw_instruction *brw_inst = brw_IF(p, BRW_EXECUTE_8); brw_inst->header.predicate_control = inst->predicate; } - if_depth_in_loop[loop_stack_depth]++; break; case BRW_OPCODE_ELSE: @@ -925,22 +918,14 @@ vec4_visitor::generate_code() break; case BRW_OPCODE_ENDIF: brw_ENDIF(p); - if_depth_in_loop[loop_stack_depth]--; break; case BRW_OPCODE_DO: brw_DO(p, BRW_EXECUTE_8); - loop_stack_depth++; - if (loop_stack_array_size <= loop_stack_depth) { - loop_stack_array_size *= 2; - if_depth_in_loop = reralloc(this->mem_ctx, if_depth_in_loop, int, - loop_stack_array_size); - } - if_depth_in_loop[loop_stack_depth] = 0; break; case BRW_OPCODE_BREAK: - brw_BREAK(p, if_depth_in_loop[loop_stack_depth]); + brw_BREAK(p); brw_set_predicate_control(p, BRW_PREDICATE_NONE); break; case BRW_OPCODE_CONTINUE: @@ -948,13 +933,11 @@ vec4_visitor::generate_code() if (intel->gen >= 6) gen6_CONT(p); else - brw_CONT(p, if_depth_in_loop[loop_stack_depth]); + brw_CONT(p); brw_set_predicate_control(p, BRW_PREDICATE_NONE); break; case BRW_OPCODE_WHILE: - assert(loop_stack_depth > 0); - loop_stack_depth--; brw_WHILE(p); break; @@ -983,8 +966,6 @@ vec4_visitor::generate_code() printf("\n"); } - ralloc_free(if_depth_in_loop); - brw_set_uip_jip(p); /* OK, while the INTEL_DEBUG=vs above is very nice for debugging VS diff --git a/src/mesa/drivers/dri/i965/brw_vs_emit.c b/src/mesa/drivers/dri/i965/brw_vs_emit.c index 62adc54c524..2b4b13a10d9 100644 --- a/src/mesa/drivers/dri/i965/brw_vs_emit.c +++ b/src/mesa/drivers/dri/i965/brw_vs_emit.c @@ -1843,8 +1843,7 @@ void brw_old_vs_emit(struct brw_vs_compile *c ) struct brw_context *brw = p->brw; struct intel_context *intel = &brw->intel; const GLuint nr_insns = c->vp->program.Base.NumInstructions; - GLuint insn, loop_depth = 0; - int if_depth_in_loop[MAX_LOOP_DEPTH]; + GLuint insn; const struct brw_indirect stack_index = brw_indirect(0, 0); GLuint index; GLuint file; @@ -1858,7 +1857,6 @@ void brw_old_vs_emit(struct brw_vs_compile *c ) brw_set_compression_control(p, BRW_COMPRESSION_NONE); brw_set_access_mode(p, BRW_ALIGN_16); - if_depth_in_loop[loop_depth] = 0; brw_set_acc_write_control(p, 1); @@ -2080,7 +2078,6 @@ void brw_old_vs_emit(struct brw_vs_compile *c ) struct brw_instruction *if_inst = brw_IF(p, BRW_EXECUTE_8); /* Note that brw_IF smashes the predicate_control field. */ if_inst->header.predicate_control = get_predicate(inst); - if_depth_in_loop[loop_depth]++; break; } case OPCODE_ELSE: @@ -2090,17 +2087,14 @@ void brw_old_vs_emit(struct brw_vs_compile *c ) case OPCODE_ENDIF: clear_current_const(c); brw_ENDIF(p); - if_depth_in_loop[loop_depth]--; break; case OPCODE_BGNLOOP: clear_current_const(c); brw_DO(p, BRW_EXECUTE_8); - loop_depth++; - if_depth_in_loop[loop_depth] = 0; break; case OPCODE_BRK: brw_set_predicate_control(p, get_predicate(inst)); - brw_BREAK(p, if_depth_in_loop[loop_depth]); + brw_BREAK(p); brw_set_predicate_control(p, BRW_PREDICATE_NONE); break; case OPCODE_CONT: @@ -2108,14 +2102,13 @@ void brw_old_vs_emit(struct brw_vs_compile *c ) if (intel->gen >= 6) { gen6_CONT(p); } else { - brw_CONT(p, if_depth_in_loop[loop_depth]); + brw_CONT(p); } brw_set_predicate_control(p, BRW_PREDICATE_NONE); break; case OPCODE_ENDLOOP: clear_current_const(c); - loop_depth--; brw_WHILE(p); break; |