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:
@@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -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;
|
||||
|
||||
@@ -301,6 +301,7 @@ typedef struct ppir_instr {
|
||||
int parent_index;
|
||||
bool scheduled;
|
||||
int offset;
|
||||
int encode_size;
|
||||
} ppir_instr;
|
||||
|
||||
typedef struct ppir_block {
|
||||
|
||||
Reference in New Issue
Block a user