mirror of
https://gitlab.freedesktop.org/mesa/mesa.git
synced 2025-12-21 15:50:11 +01:00
i965: Don't make consumers of brw_WHILE do pre-gen6 BREAK/CONT patching.
The EU code itself can just do this work, since all the consumers were duplicating it. Reviewed-by: Yuanhan Liu <yuanhan.liu@linux.intel.com>
This commit is contained in:
parent
32118cfe37
commit
ce6be334bb
4 changed files with 44 additions and 85 deletions
|
|
@ -1343,7 +1343,35 @@ struct brw_instruction *brw_DO(struct brw_compile *p, GLuint execute_size)
|
|||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* For pre-gen6, we patch BREAK/CONT instructions to point at the WHILE
|
||||
* instruction here.
|
||||
*
|
||||
* For gen6+, see brw_set_uip_jip(), which doesn't care so much about the loop
|
||||
* nesting, since it can always just point to the end of the block/current loop.
|
||||
*/
|
||||
static void
|
||||
brw_patch_break_cont(struct brw_compile *p, struct brw_instruction *while_inst)
|
||||
{
|
||||
struct intel_context *intel = &p->brw->intel;
|
||||
struct brw_instruction *do_inst = get_inner_do_insn(p);
|
||||
struct brw_instruction *inst;
|
||||
int br = (intel->gen == 5) ? 2 : 1;
|
||||
|
||||
for (inst = while_inst - 1; inst != do_inst; inst--) {
|
||||
/* If the jump count is != 0, that means that this instruction has already
|
||||
* been patched because it's part of a loop inside of the one we're
|
||||
* patching.
|
||||
*/
|
||||
if (inst->header.opcode == BRW_OPCODE_BREAK &&
|
||||
inst->bits3.if_else.jump_count == 0) {
|
||||
inst->bits3.if_else.jump_count = br * ((while_inst - inst) + 1);
|
||||
} else if (inst->header.opcode == BRW_OPCODE_CONTINUE &&
|
||||
inst->bits3.if_else.jump_count == 0) {
|
||||
inst->bits3.if_else.jump_count = br * (while_inst - inst);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
struct brw_instruction *brw_WHILE(struct brw_compile *p)
|
||||
{
|
||||
|
|
@ -1352,7 +1380,6 @@ struct brw_instruction *brw_WHILE(struct brw_compile *p)
|
|||
GLuint br = 1;
|
||||
|
||||
do_insn = get_inner_do_insn(p);
|
||||
p->loop_stack_depth--;
|
||||
|
||||
if (intel->gen >= 5)
|
||||
br = 2;
|
||||
|
|
@ -1396,11 +1423,15 @@ struct brw_instruction *brw_WHILE(struct brw_compile *p)
|
|||
insn->bits3.if_else.jump_count = br * (do_insn - insn + 1);
|
||||
insn->bits3.if_else.pop_count = 0;
|
||||
insn->bits3.if_else.pad0 = 0;
|
||||
|
||||
brw_patch_break_cont(p, insn);
|
||||
}
|
||||
}
|
||||
insn->header.compression_control = BRW_COMPRESSION_NONE;
|
||||
p->current->header.predicate_control = BRW_PREDICATE_NONE;
|
||||
|
||||
p->loop_stack_depth--;
|
||||
|
||||
return insn;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -658,8 +658,6 @@ fs_visitor::generate_code()
|
|||
|
||||
int loop_stack_array_size = 16;
|
||||
int loop_stack_depth = 0;
|
||||
brw_instruction **loop_stack =
|
||||
rzalloc_array(this->mem_ctx, brw_instruction *, loop_stack_array_size);
|
||||
int *if_depth_in_loop =
|
||||
rzalloc_array(this->mem_ctx, int, loop_stack_array_size);
|
||||
|
||||
|
|
@ -795,11 +793,10 @@ fs_visitor::generate_code()
|
|||
break;
|
||||
|
||||
case BRW_OPCODE_DO:
|
||||
loop_stack[loop_stack_depth++] = brw_DO(p, BRW_EXECUTE_8);
|
||||
brw_DO(p, BRW_EXECUTE_8);
|
||||
loop_stack_depth++;
|
||||
if (loop_stack_array_size <= loop_stack_depth) {
|
||||
loop_stack_array_size *= 2;
|
||||
loop_stack = reralloc(this->mem_ctx, loop_stack, brw_instruction *,
|
||||
loop_stack_array_size);
|
||||
if_depth_in_loop = reralloc(this->mem_ctx, if_depth_in_loop, int,
|
||||
loop_stack_array_size);
|
||||
}
|
||||
|
|
@ -819,31 +816,10 @@ fs_visitor::generate_code()
|
|||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||
break;
|
||||
|
||||
case BRW_OPCODE_WHILE: {
|
||||
struct brw_instruction *inst0, *inst1;
|
||||
GLuint br = 1;
|
||||
|
||||
if (intel->gen >= 5)
|
||||
br = 2;
|
||||
|
||||
case BRW_OPCODE_WHILE:
|
||||
assert(loop_stack_depth > 0);
|
||||
loop_stack_depth--;
|
||||
inst0 = inst1 = brw_WHILE(p);
|
||||
if (intel->gen < 6) {
|
||||
/* patch all the BREAK/CONT instructions from last BGNLOOP */
|
||||
while (inst0 > loop_stack[loop_stack_depth]) {
|
||||
inst0--;
|
||||
if (inst0->header.opcode == BRW_OPCODE_BREAK &&
|
||||
inst0->bits3.if_else.jump_count == 0) {
|
||||
inst0->bits3.if_else.jump_count = br * (inst1 - inst0 + 1);
|
||||
}
|
||||
else if (inst0->header.opcode == BRW_OPCODE_CONTINUE &&
|
||||
inst0->bits3.if_else.jump_count == 0) {
|
||||
inst0->bits3.if_else.jump_count = br * (inst1 - inst0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
brw_WHILE(p);
|
||||
break;
|
||||
|
||||
case SHADER_OPCODE_RCP:
|
||||
|
|
@ -947,7 +923,6 @@ fs_visitor::generate_code()
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
ralloc_free(loop_stack);
|
||||
ralloc_free(if_depth_in_loop);
|
||||
|
||||
brw_set_uip_jip(p);
|
||||
|
|
|
|||
|
|
@ -800,8 +800,6 @@ vec4_visitor::generate_code()
|
|||
|
||||
int loop_stack_array_size = 16;
|
||||
int loop_stack_depth = 0;
|
||||
brw_instruction **loop_stack =
|
||||
rzalloc_array(this->mem_ctx, brw_instruction *, loop_stack_array_size);
|
||||
int *if_depth_in_loop =
|
||||
rzalloc_array(this->mem_ctx, int, loop_stack_array_size);
|
||||
|
||||
|
|
@ -931,11 +929,10 @@ vec4_visitor::generate_code()
|
|||
break;
|
||||
|
||||
case BRW_OPCODE_DO:
|
||||
loop_stack[loop_stack_depth++] = brw_DO(p, BRW_EXECUTE_8);
|
||||
brw_DO(p, BRW_EXECUTE_8);
|
||||
loop_stack_depth++;
|
||||
if (loop_stack_array_size <= loop_stack_depth) {
|
||||
loop_stack_array_size *= 2;
|
||||
loop_stack = reralloc(this->mem_ctx, loop_stack, brw_instruction *,
|
||||
loop_stack_array_size);
|
||||
if_depth_in_loop = reralloc(this->mem_ctx, if_depth_in_loop, int,
|
||||
loop_stack_array_size);
|
||||
}
|
||||
|
|
@ -955,31 +952,10 @@ vec4_visitor::generate_code()
|
|||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||
break;
|
||||
|
||||
case BRW_OPCODE_WHILE: {
|
||||
struct brw_instruction *inst0, *inst1;
|
||||
GLuint br = 1;
|
||||
|
||||
if (intel->gen >= 5)
|
||||
br = 2;
|
||||
|
||||
case BRW_OPCODE_WHILE:
|
||||
assert(loop_stack_depth > 0);
|
||||
loop_stack_depth--;
|
||||
inst0 = inst1 = brw_WHILE(p);
|
||||
if (intel->gen < 6) {
|
||||
/* patch all the BREAK/CONT instructions from last BGNLOOP */
|
||||
while (inst0 > loop_stack[loop_stack_depth]) {
|
||||
inst0--;
|
||||
if (inst0->header.opcode == BRW_OPCODE_BREAK &&
|
||||
inst0->bits3.if_else.jump_count == 0) {
|
||||
inst0->bits3.if_else.jump_count = br * (inst1 - inst0 + 1);
|
||||
}
|
||||
else if (inst0->header.opcode == BRW_OPCODE_CONTINUE &&
|
||||
inst0->bits3.if_else.jump_count == 0) {
|
||||
inst0->bits3.if_else.jump_count = br * (inst1 - inst0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
brw_WHILE(p);
|
||||
break;
|
||||
|
||||
default:
|
||||
|
|
@ -1007,7 +983,6 @@ vec4_visitor::generate_code()
|
|||
printf("\n");
|
||||
}
|
||||
|
||||
ralloc_free(loop_stack);
|
||||
ralloc_free(if_depth_in_loop);
|
||||
|
||||
brw_set_uip_jip(p);
|
||||
|
|
|
|||
|
|
@ -1844,7 +1844,6 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
|
|||
struct intel_context *intel = &brw->intel;
|
||||
const GLuint nr_insns = c->vp->program.Base.NumInstructions;
|
||||
GLuint insn, loop_depth = 0;
|
||||
struct brw_instruction *loop_inst[MAX_LOOP_DEPTH] = { 0 };
|
||||
int if_depth_in_loop[MAX_LOOP_DEPTH];
|
||||
const struct brw_indirect stack_index = brw_indirect(0, 0);
|
||||
GLuint index;
|
||||
|
|
@ -2095,7 +2094,8 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
|
|||
break;
|
||||
case OPCODE_BGNLOOP:
|
||||
clear_current_const(c);
|
||||
loop_inst[loop_depth++] = brw_DO(p, BRW_EXECUTE_8);
|
||||
brw_DO(p, BRW_EXECUTE_8);
|
||||
loop_depth++;
|
||||
if_depth_in_loop[loop_depth] = 0;
|
||||
break;
|
||||
case OPCODE_BRK:
|
||||
|
|
@ -2113,32 +2113,10 @@ void brw_old_vs_emit(struct brw_vs_compile *c )
|
|||
brw_set_predicate_control(p, BRW_PREDICATE_NONE);
|
||||
break;
|
||||
|
||||
case OPCODE_ENDLOOP: {
|
||||
case OPCODE_ENDLOOP:
|
||||
clear_current_const(c);
|
||||
struct brw_instruction *inst0, *inst1;
|
||||
GLuint br = 1;
|
||||
|
||||
loop_depth--;
|
||||
|
||||
if (intel->gen == 5)
|
||||
br = 2;
|
||||
|
||||
inst0 = inst1 = brw_WHILE(p);
|
||||
|
||||
if (intel->gen < 6) {
|
||||
/* patch all the BREAK/CONT instructions from last BEGINLOOP */
|
||||
while (inst0 > loop_inst[loop_depth]) {
|
||||
inst0--;
|
||||
if (inst0->header.opcode == BRW_OPCODE_BREAK &&
|
||||
inst0->bits3.if_else.jump_count == 0) {
|
||||
inst0->bits3.if_else.jump_count = br * (inst1 - inst0 + 1);
|
||||
} else if (inst0->header.opcode == BRW_OPCODE_CONTINUE &&
|
||||
inst0->bits3.if_else.jump_count == 0) {
|
||||
inst0->bits3.if_else.jump_count = br * (inst1 - inst0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
brw_WHILE(p);
|
||||
break;
|
||||
|
||||
case OPCODE_BRA:
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue