lima/ppir: Fix branch codegen

"unknown_2" field is actually a size of instruction that branch
points to. If it's set to a smaller size than actual instruction
branch behavior is not defined (and it usually wedges the GPU).

Fix it by setting this field correctly.

Fixes: af0de6b91c ("lima/ppir: implement discard and discard_if")
Reviewed-by: Qiang Yu <yuq825@gmail.com>
Signed-off-by: Vasily Khoruzhick <anarsoul@gmail.com>
This commit is contained in:
Vasily Khoruzhick
2019-07-14 18:22:36 -07:00
parent 8f0160ca24
commit eb862c2365
3 changed files with 5 additions and 3 deletions
+3 -2
View File
@@ -543,10 +543,10 @@ static void ppir_codegen_encode_branch(ppir_node *node, void *code)
b->branch.cond_eq = branch->cond_eq;
b->branch.cond_lt = branch->cond_lt;
b->branch.unknown_1 = 0x0;
b->branch.unknown_2 = 0x3;
target_instr = list_first_entry(&branch->target->instr_list, ppir_instr, list);
b->branch.target = target_instr->offset - node->instr->offset;
b->branch.next_count = target_instr->encode_size;
}
typedef void (*ppir_codegen_instr_slot_encode_func)(ppir_node *, void *);
@@ -699,7 +699,8 @@ bool ppir_codegen_prog(ppir_compiler *comp)
list_for_each_entry(ppir_block, block, &comp->block_list, list) {
list_for_each_entry(ppir_instr, instr, &block->instr_list, list) {
instr->offset = size;
size += get_instr_encode_size(instr);
instr->encode_size = get_instr_encode_size(instr);
size += instr->encode_size;
}
}
+1 -1
View File
@@ -345,7 +345,7 @@ typedef union __attribute__((__packed__)) {
bool cond_lt : 1;
unsigned unknown_1 : 22; /* = 0 0000 0000 0000 0000 0000 0 */
signed target : 27;
unsigned unknown_2 : 5; /* = 0 0011 */
unsigned next_count : 5;
} branch;
struct __attribute__((__packed__)) {
unsigned word0 : 32;
+1
View File
@@ -301,6 +301,7 @@ typedef struct ppir_instr {
int parent_index;
bool scheduled;
int offset;
int encode_size;
} ppir_instr;
typedef struct ppir_block {